0

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. 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. 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.

How do I get Ruby on Rails and subsequently, Locomotive CMS running on Windows 10?


Note: I initially followed this tutorial to install Ruby with RubyInstaller. 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:

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...
Luke
  • 4,825
  • 2
  • 30
  • 37
  • Just out of curiosity. Is your installation procedure different from this one? https://gorails.com/setup/windows/10 – did Aug 28 '20 at 20:14
  • Yes it’s completely different. I actually tried the one you linked to first - I figured running RoR on Windows WSL would be ideal as I would have a true Linux environment. But I ran into trouble installing gems. Was constantly having to use “sudo” to install everything which I’ve heard isn’t a good idea. And when I finally came to install locomotivecms_wagon it failed due to the version of nokogiri. I don’t remember the details but I came to the (perhaps incorrect) conclusion that it wasn’t ever going to work and went instead for [RubyInstaller](https://rubyinstaller.org/downloads/). – Luke Aug 28 '20 at 23:30
  • Finally gave up on RubyInstaller. It worked well for me in a Windows 7 environment but I could not get locomotivecms_wagon to install using it under Windows 10. I did 3 complete install and uninstalls and ran into different problems every time, but all to do with Nokogiri or Nokogumbo. Those Noko gems don't play well with others. – Luke Aug 30 '20 at 08:37
  • 1
    I've instead set up Windows WSL. Also took 2 attempts but eventually got there and have locomotivecms_wagon installed and it appears to be working. Locomotive CMS Wagon will not work on Ruby higher than 2.5.8 - as there are dependency issues with...you guessed it: Nokogumbo. – Luke Aug 30 '20 at 08:39
  • interesting. Do you have the same issue as this user? https://github.com/rubys/nokogumbo/issues/146 – did Aug 31 '20 at 16:03
  • I don’t think it’s the same issue. Because nokogumbo installed along with all the other gems. It’s only when I came to install Locomotive CMS that this issue appeared. (Although I did have a number of issues installing nokogiri). – Luke Aug 31 '20 at 21:42

2 Answers2

1

After 3 installs, uninstalls and reinstalls I gave up on RubyInstaller. RubyInstaller worked great for me running Windows 7 - I doubt I ever would have managed to get a working Ruby environment without it. 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.

What worked for me was setting up WSL (Windows SubSystem for Linux) and installing Ruby on that. I followed the Go Rails tutorial in conjunction with these instructions.

I highly recommend updating the WSL Linux kernel (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.

(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.)

When you get to installing Ruby, don't install 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:

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.

I used rbenv as opposed to 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. I am concerned about how it is going to handle changes made via Ubuntu vs changes made via Windows. And I will need to make some changes via Windows - doing everything through the terminal isn't realistic. 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. Not sure whether the fact that I will be creating / editing them under Ubuntu will have any implications.
Luke
  • 4,825
  • 2
  • 30
  • 37
0

I've found a similar GitHub issue here: 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.

did
  • 181
  • 1
  • 2
  • If I run `gem install nokogumbo -- --with-ldflags=-no-undefined` I get an error message saying (among many other things) that 'extconf.rb failed', 'Could not create Makefile', 'The compiler failed to generate the executabe file', 'You have to install development tools first', etc. MSYS2 is already installed though... – Luke Aug 29 '20 at 07:36