【问题标题】:Can't Install / Use LocomotiveCMS Wagon on Windows 10无法在 Windows 10 上安装/使用 LocomotiveCMS Wagon
【发布时间】:2020-08-27 09:37:26
【问题描述】:

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

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

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


注意:我最初是按照 this tutorial 使用 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...

【问题讨论】:

  • 只是出于好奇。您的安装过程与此不同吗? gorails.com/setup/windows/10
  • 是的,它完全不同。我实际上尝试了您首先链接到的那个 - 我认为在 Windows WSL 上运行 RoR 将是理想的,因为我将拥有一个真正的 Linux 环境。但是我在安装 gems 时遇到了麻烦。经常不得不使用“sudo”来安装我听说过的所有东西,这不是一个好主意。当我终于来安装 locomotivecms_wagon 时,由于 nokogiri 的版本而失败了。我不记得细节了,但我得出的(可能是不正确的)结论是它永远不会起作用,而是选择了RubyInstaller
  • 终于放弃了RubyInstaller。它在 Windows 7 环境中运行良好,但我无法在 Windows 10 下使用 locomotivecms_wagon 进行安装。我进行了 3 次完整的安装和卸载,每次都遇到不同的问题,但都与 Nokogiri 或 Nokogumbo 有关。那些 Noko 宝石不能很好地与其他人一起玩。
  • 我设置了 Windows WSL。也进行了 2 次尝试,但最终到达那里并安装了 locomotivecms_wagon,它似乎正在工作。 Locomotive CMS Wagon 不能在高于 2.5.8 的 Ruby 上工作 - 因为存在依赖问题......你猜对了:Nokogumbo。
  • 有趣。你和这个用户有同样的问题吗? github.com/rubys/nokogumbo/issues/146

标签: ruby windows nokogiri locomotivecms nokogumbo


【解决方案1】:

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

对我有用的是设置 WSL (Windows SubSystem for Linux) 并在其上安装 Ruby。我关注了Go Rails tutorialthese instructions

我强烈推荐updating the WSL Linux kernel (WSL 1 > WSL 2)。我第一次没有这样做,并且遇到了各种问题。 This GitHub tutorial 有助于确定您是否安装了 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.1.0 上运行 Locomotive CMS。

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

在完成所有这些之后,我能够轻松设置以下内容:

一些注意事项:

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

【讨论】:

    【解决方案2】:

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

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

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

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

    【讨论】:

    • 如果我运行gem install nokogumbo -- --with-ldflags=-no-undefined,我会收到一条错误消息(其中包括)'extconf.rb failed'、'Could not create Makefile'、'The compiler failed to generate the executabe file ', '你必须先安装开发工具' 等等。MSYS2 已经安装了...
    猜你喜欢
    • 2019-12-03
    • 2019-10-11
    • 1970-01-01
    • 2022-10-21
    • 1970-01-01
    • 2018-11-30
    • 2020-11-02
    • 2020-05-03
    • 2021-06-18
    相关资源
    最近更新 更多