0

这开始是关于特定 gem 安装问题的问题,但我经历了如此多的问题迭代,试图让这个应用程序在 Windows 10 上运行,我决定改变这个问题并编写一种指南。希望这对将来遇到这些问题的其他人(或我自己)有用。

我正在运行 Windows 10 64 位机器。我已经尝试过 RubyInstaller 并为 Linux (WSL) 设置了 Windows 子系统,并且遇到了各种安装问题、gem 依赖问题,并且直接模糊为任何谁知道什么问题。

如何获得 Ruby on Rails 以及随后在 Windows 10 上运行的 Locomotive CMS?


注意:我最初按照本教程使用 RubyInstaller 安装 Ruby。这显然工作得很好(尽管在此过程中出现了一些小问题),但我最终在尝试时遇到了以下错误gem install locomotivecms_wagon,我无法解决:

ERROR:  Error installing locomotivecms_wagon:
    ERROR: Failed to build gem native extension.

current directory: C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/gems/2.5.0/gems/nokogumbo-1.5.0/ext/nokogumboc
C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/bin/ruby.exe -I C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/site_ruby/2.5.0 -r ./siteconf20200827-12272-1va06mr.rb extconf.rb
checking for xmlNewDoc() in -lxml2... yes
checking for nokogiri.h in C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.10/ext/nokogiri... yes
checking for nokogiri.h in C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.10/ext/nokogiri... yes
checking for gumbo_parse() in -lgumbo... no
checking for GumboErrorType with error.h... not found
checking for GumboInsertionMode with insertion_mode.h... not found
checking for GumboParser with parser.h... not found
checking for GumboStringBuffer with string_buffer.h... not found
checking for GumboTokenType with token_type.h... not found
creating Makefile

current directory: C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/gems/2.5.0/gems/nokogumbo-1.5.0/ext/nokogumboc
make "DESTDIR=" clean

current directory: C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/gems/2.5.0/gems/nokogumbo-1.5.0/ext/nokogumboc
make "DESTDIR="
generating nokogumboc-x64-mingw32.def
compiling attribute.c
compiling char_ref.c
compiling error.c
compiling nokogumbo.c
In file included from nokogumbo.c:31:
C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.10/ext/nokogiri/nokogiri.h:13: warning: "_GNU_SOURCE" redefined
   13 | #define _GNU_SOURCE
      |
In file included from C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/include/ruby-2.5.0/ruby/ruby.h:24,
             from C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/include/ruby-2.5.0/ruby.h:33,
             from nokogumbo.c:21:
C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/include/ruby-2.5.0/x64-mingw32/ruby/config.h:18: note: this is the location of the previous definition
   18 | #define _GNU_SOURCE 1
      |
compiling parser.c
compiling string_buffer.c
compiling string_piece.c
compiling tag.c
compiling tokenizer.c
compiling utf8.c
compiling util.c
compiling vector.c
linking shared-object nokogumboc.so
C:/Dev/Dependencies/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: nokogumbo.o:nokogumbo.c:(.text+0x49b): undefined reference to 'Nokogiri_wrap_xml_document'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:259: nokogumboc.so] Error 1

make failed, exit code 2

Gem files will remain installed in C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/gems/2.5.0/gems/nokogumbo-1.5.0 for inspection.
Results logged to C:/Dev/Dependencies/rubyinstaller-2.5.8-1-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/nokogumbo-1.5.0/gem_make.out
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
4

2 回答 2

1

在 3 次安装、卸载和重新安装后,我放弃了RubyInstaller。RubyInstaller 非常适合运行 Windows 7 的我——我怀疑没有它我是否会设法获得一个工作的 Ruby 环境。它可能适用于 Windows 10 上的某些事情。我设置得很好,但我无法根据我的问题中的问题安装Locomotive CMS Wagon gem。

对我有用的是设置WSL(Linux 的 Windows 子系统)并在其上安装 Ruby。我结合这些说明遵循了Go Rails 教程

我强烈建议更新 WSL Linux 内核(WSL 1 > WSL 2)。我第一次没有这样做,并且遇到了各种问题。此 GitHub 教程有助于确定您是否安装了 WSL 1 或 2。

(我并不担心创建另一个用户,如 GitHub 教程中所述,因为我在第一次启动 Ubuntu 时被提示这样做。据我所知,这是防止用户与 root 权限问题所必需的.我还没有遇到任何问题。)

当你开始安装 Ruby 时,不要安装 2.7.1。如果这样做,那么当您开始安装 locomotivecms_wagon 时,截至撰写本文时,您将遇到以下问题:

Bundler found conflicting requirements for the Ruby version:
In Gemfile:
Ruby

locomotivecms_steam was resolved to 1.5.0.rc0, which depends on
  nokogiri (~> 1.8.2) was resolved to 1.8.5, which depends on
    Ruby (>= 2.1.0)

locomotivecms_steam was resolved to 1.5.0.rc0, which depends on
  nokogiri (~> 1.8.2) was resolved to 1.8.5, which depends on
    Ruby (< 2.6, >= 2.2) x64-mingw32

据我所知,您只能在 Ruby < 2.6 或 >= 2.1.0 上运行 Locomotive CMS。

我使用 rbenv 而不是 rvm。那是另一个讨论。

在完成所有这些之后,我能够毫不费力地设置以下内容:

一些警告:

  • 我还没有在 WSL 上设置 Git。我担心它将如何处理通过 Ubuntu 所做的更改与通过 Windows 所做的更改。而且我需要通过 Windows 进行一些更改——通过终端做所有事情是不现实的。不知道会怎样。当我发现时,我可能会用更多信息更新这个答案。
  • 我所有的文件都包含在 Dropbox 文件夹中。不确定我将在 Ubuntu 下创建/编辑它们的事实是否会产生任何影响。
于 2020-08-30T09:24:18.413 回答
0

我在这里发现了一个类似的 GitHub 问题:https ://github.com/rubys/nokogumbo/issues/4 。

他们提到了以下声明作为解决方案:

gem install nokogumbo -- --with-ldflags=-no-undefined

运行此命令,然后重新运行bundle install.

于 2020-08-28T20:13:14.750 回答