简体   繁体   English

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

[英]Can't Install / Use LocomotiveCMS Wagon on Windows 10

This started as a question about a specific gem installation issue but I went through so many iterations of issues trying to get this application working on Windows 10 that I decided to alter the question and write a sort of guide.这开始是一个关于特定 gem 安装问题的问题,但我经历了很多问题的迭代,试图让这个应用程序在 Windows 10 上运行,我决定改变这个问题并编写一种指南。 Hopefully this will be of use to anyone else (or myself) experiencing these issues in the future.希望这对将来遇到这些问题的任何其他人(或我自己)有用。

I am running a Windows 10 64 bit machine.我正在运行 Windows 10 64 位机器。 I have tried RubyInstaller and setting up Windows SubSystem for Linux (WSL) and have been met with various installation issues, gem dependency issues and just straight out vague as anything who-knows-what issues.我已经尝试过 RubyInstaller 并为 Linux (WSL) 设置了 Windows 子系统,但遇到了各种安装问题、gem 依赖问题,并且直接说不清楚是什么问题。

How do I get Ruby on Rails and subsequently, Locomotive CMS running on Windows 10?我如何获得 Ruby on Rails 以及随后在 Windows 10 上运行的 Locomotive CMS?


Note: I initially followed this tutorial to install Ruby with RubyInstaller.注意:我最初按照本教程使用 RubyInstaller 安装 Ruby。 This apparently worked fine (although there were a fair few hiccups along the way), but I eventually ended up with the following error when attempting to gem install locomotivecms_wagon , which I was unable to solve:这显然工作正常(虽然一路上有一些小问题),但我最终在尝试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...

After 3 installs, uninstalls and reinstalls I gave up on RubyInstaller . 3 次安装、卸载和重新安装后,我放弃了RubyInstaller RubyInstaller worked great for me running Windows 7 - I doubt I ever would have managed to get a working Ruby environment without it. RubyInstaller 对运行 Windows 7 的我来说效果很好——我怀疑如果没有它,我是否会设法获得一个工作的 Ruby 环境。 And it may have worked for some things on Windows 10. I got it set up ok, but I could not get the Locomotive CMS Wagon gem to install as per the issue in my question.它可能在 Windows 10 上对某些事情有效。我已经设置好了,但我无法根据我的问题中的问题安装Locomotive CMS Wagon gem。

What worked for me was setting up WSL (Windows SubSystem for Linux) and installing Ruby on that.对我有用的是设置WSL(Linux 的 Windows 子系统)并在其上安装 Ruby。 I followed the Go Rails tutorial in conjunction with these instructions .我按照Go Rails 教程这些说明进行了操作

I highly recommend updating the WSL Linux kernel (WSL 1 > WSL 2).我强烈建议更新 WSL Linux 内核(WSL 1 > WSL 2)。 I didn't do this the first time around and had various problems.我第一次没有这样做,并且遇到了各种问题。 This GitHub tutorial helps with identifying whether you have WSL 1 or 2 installed. 本 GitHub 教程有助于确定您是否安装了 WSL 1 或 2。

(I didn't worry about creating another user as described in the GitHub tutorial as I was prompted to do this on starting Ubuntu for the first time. As far as I can tell this is what is required to prevent the user vs root permissions problems. I haven't had any issues yet.) (我并不担心像 GitHub 教程中描述的那样创建另一个用户,因为我在第一次启动 Ubuntu 时被提示这样做。据我所知,这是防止用户与 root 权限问题所必需的.我还没有遇到任何问题。)

When you get to installing Ruby, don't install 2.7.1.当你开始安装 Ruby 时,不要安装 2.7.1。 If you do, then when you get to installing locomotivecms_wagon, as of the time of writing, you will run into the following issue:如果你这样做了,那么当你开始安装 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

From what I can gather, you can only run Locomotive CMS on Ruby < 2.6 or >= 2.1.0.据我所知,您只能在 Ruby < 2.6 或 >= 2.1.0 上运行 Locomotive CMS。

I used rbenv as opposed to rvm.我使用 rbenv 而不是 rvm。 That's another discussion.那是另一个讨论。

After making my way through all that I was able to set up the following without too much trouble:在完成所有这些之后,我能够毫不费力地设置以下内容:

A few caveats:一些注意事项:

  • I haven't yet set up Git on WSL.我还没有在 WSL 上设置 Git。 I am concerned about how it is going to handle changes made via Ubuntu vs changes made via Windows.我担心它将如何处理通过 Ubuntu 所做的更改与通过 Windows 所做的更改。 And I will need to make some changes via Windows - doing everything through the terminal isn't realistic.而且我需要通过 Windows 进行一些更改 - 通过终端做所有事情是不现实的。 Not sure how that is going to go.不知道会怎样。 I might update this answer with further info when I find out.当我发现时,我可能会用更多信息更新这个答案。
  • All my files are contained within a Dropbox folder.我的所有文件都包含在 Dropbox 文件夹中。 Not sure whether the fact that I will be creating / editing them under Ubuntu will have any implications.不确定我将在 Ubuntu 下创建/编辑它们的事实是否会产生任何影响。

I've found a similar GitHub issue here: https://github.com/rubys/nokogumbo/issues/4 .我在这里发现了一个类似的 GitHub 问题: https : //github.com/rubys/nokogumbo/issues/4

They mentioned the following statement as a solution:他们提到了以下声明作为解决方案:

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

Run this command and then re-run bundle install .运行此命令,然后重新运行bundle install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM