在Windows 10上无法安装/使用LocomotiveCMS Wagon

问题描述

这最初是关于一个特定的gem安装问题的问题,但是为了使该应用程序在Windows 10上正常工作,我经历了很多迭代的问题,因此我决定更改问题并编写某种指南。希望这对将来遇到这些问题的其他人(或我本人)有用。

我正在运行Windows 10 64位计算机。我已经尝试过RubyInstaller并设置了Linux的Windows子系统(WSL),并且遇到了各种安装问题,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...

解决方法

安装3后,我在RubyInstaller上放弃并重新安装了。 RubyInstaller对运行Windows 7的我非常有用-我怀疑如果没有它,我是否能够设法获得一个正常的Ruby环境。而且它可能已经在Windows 10上运行了。我按它的设置就可以了,但是我无法根据问题中的问题安装机车CMS Wagon 宝石。

对我有用的是设置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时会这样做。据我所知,这是防止用户vs 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
    Ruby (< 2.6,>= 2.2) x64-mingw32

据我所知,您只能在Ruby = 2.1.0上运行机车CMS。

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

在完成所有工作之后,我可以很轻松地进行以下设置:

一些警告:

  • 我尚未在WSL上设置Git。我担心它将如何处理通过Ubuntu和Windows进行的更改。我将需要通过Windows进行一些更改-通过终端执行所有操作都是不现实的。不知道怎么回事。找出答案后,我可能会使用更多信息来更新此答案。
  • 我的所有文件都包含在Dropbox文件夹中。不确定我将在Ubuntu下创建/编辑它们的事实是否会产生任何影响。
,

我在这里找到了类似的GitHub问题:https://github.com/rubys/nokogumbo/issues/4

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

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

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