Can't Install / Use LocomotiveCMS Wagon on Windows 10 - ruby

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

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:
Install Node.js as per these instructions.
Install Yarn as per these instructions: npm install -g yarn
Install Image Magick as per these instructions: sudo apt-get install imagemagick
Install Locomotive CMS as per the Locomotive CMS docs: gem install locomotivecms_wagon
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.

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.

Related

What's the best way to add a C include path when using `bundle install`?

As background, I have extensive knowledge of software build systems, Unix (I'm using Debian 11 in this instance) and Python environments, but almost no knowledge of modern Ruby environments.
I'm wanting to write a post in a friend's blog built with Jekyll and so am trying to get his blog building in development mode on my system. I'm wanting to minimise the amount of Ruby stuff I bring in using system packages, so I'm using bundle install --path vendor/bundle to set up the project dependencies, which include the rmagick gem.
I've installed the libmagickcore-6.q16-dev package, which gives me /usr/include/ImageMagick-6/wand/MagickWand.h. However, bundler is unable to install the RMagick 2.16.0 gem.
Looking in vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/rmagick-2.16.0/mkmf.log, this seems to be the failure:
have_header: checking for wand/MagickWand.h... -------------------- no
"x86_64-linux-gnu-gcc -E -I/usr/include/x86_64-linux-gnu/ruby-2.7.0 -I/usr/include/ruby-2.7.0/ruby/backward -I/usr/include/ruby-2.7.0 -I. conftest.c -o conftest.i"
conftest.c:3:10: fatal error: wand/MagickWand.h: No such file or directory
3 | #include <wand/MagickWand.h>
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
Without doing extensive further investigation, I'm guessing that this is due to the include path being incorrect. This kind of hints at the RMagick gem being broken, since pkg-config does supply this:
$ pkg-config --cflags MagickCore
-fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6
I'm not able to upgrade the Gems that he's using, nor even easily test that any changes I might make on my system work on the systems he's using. So to work around this I'd like to get bundle to add -I /usr/include/ImageMagick-6 (or do the moral equivalent).
What's the best way to make this happen? I don't see a bundle command line option for this. Perhaps there's an environment variable I can set?
It turns out that the RMagick was using the correct include paths, though these were not displayed in the mkmf.log file above. The issue was that I actually didn't have the include file itself, despite pkg-config --cflags MagickCore giving the path to the wand/ subdirectory.
I'd installed the Debian 11 package libmagickcore-6.q16-dev, which supplies MagickCore.pc, based on an earlier error indicating that pkg-config MagickCore was failing. However, the RMagic package actually requires a different library/set of headers, supplied by the libmagickwand-6.q16-dev package. After installing that, bundle appeared to build the RMagick gem without difficulty.
While debugging this I did come across a list of GCC environment variables, and it seems as if the C_INCLUDE_PATH one mentioned there might solve the original problem I'd posted above. However, I've no easy way of testing this right now.

Installing Ruby 1.9.x on macOS 10.13 (High Sierra)

I've recently decided to look at an old Rails app running Ruby 1.9.2 and decided to try to install 1.9.2 on my macOS 10.13 machine.
I'm aware that gcc no longer ships with macOS so I remembered the old trick of using Homebrew Core's apple-gcc42 recipe, sadly the maximum version this works with is 10.9 (Mavericks). I tried my luck anyway and even followd rbenv's gcc compatibility notes:
(Note that Ruby < 2.0 does not have the with-readline-dir flag; use with-opt-dir instead.)
I tried the following command (note that I have rbenv's ruby-build plugin installed and up-to-date):
RUBY_CONFIGURE_OPTS="--with-opt-dir=/usr/local/opt/" CC=/usr/local/bin/gcc-4.2 rbenv install 1.9.2-p180
ruby-build: use libyaml from homebrew
Downloading ruby-1.9.2-p180.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.bz2
Installing ruby-1.9.2-p180...
WARNING: ruby-1.9.2-p180 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: use readline from homebrew
BUILD FAILED (OS X 10.13.3 using ruby-build 20180329)
Inspect or clean up the working tree at /var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949
Results logged to /var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949.log
Last 10 log lines:
/var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949 /usr/local/bin
/var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949/ruby-1.9.2-p180 /var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949 /usr/local/bin
configure: WARNING: unrecognized options: --with-openssl-dir, --with-libyaml-dir, --with-readline-dir
checking build system type... i386-apple-darwin17.4.0
checking host system type... i386-apple-darwin17.4.0
checking target system type... i386-apple-darwin17.4.0
checking whether the C compiler works... no
configure: error: in `/var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949/ruby-1.9.2-p180':
configure: error: C compiler cannot create executables
See `config.log' for more details
The error on the config.log is the same as the one output above:
configure:3446: error: C compiler cannot create executables
I tried to compile a basic file with C code and gcc-4.2 failed to do so (unlike /usr/local/bin/gcc) which I tells me gcc-4.2 simply doesn't work on macOS 10.13 right now. Perhaps the only way forward would be to find a way to compile old Rubies with modern gcc versions, but I'm guessing that might involve making a lot of manual changes to the configure files to make them compatible.
I'm just curious if anyone's succeeded in this endeavor or if this is a lost cause.
It's probably possible with rvm have a look at https://github.com/rvm/rvm/issues/3099 and also https://github.com/rvm/rvm/issues/3876
You should be able to install ruby-1.9.3
But if that doesn't work, you might consider spinning up a docker ubuntu container and install it that way? https://github.com/rvm/ubuntu_rvm

Cannot install gem - make is not recognized as an internal or external command operable program or batch file

I wanted to install the rspec-rails gem with ruby 1.9.3 on windows 7. I got some errors saying that some json libraries could not be installed. So, I used the instructions below to solve it.
Source = The 'json' native gem requires installed build tools
Download [Ruby 1.9.3][2] from [rubyinstaller.org][3]
Download DevKit file from [rubyinstaller.org][3]
For Ruby 1.9.3 use [DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe][4]
Extract DevKit to path C:\Ruby193\DevKit
Run cd C:\Ruby193\DevKit
Run ruby dk.rb init
Run ruby dk.rb review
Run ruby dk.rb install
To return to the problem at hand, you should be able to install JSON (or otherwise test that your DevKit successfully installed) by running the following commands which will perform an install of the JSON gem and then use it:
gem install json --platform=ruby
ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect"
When I execute the above first step, I get the error -
C:\Ruby193\DevKit>gem install json --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
'make' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
I am trying to solve the above error now -
'make' is not recognized as an internal or external command, operable program or batch file.
using make is not recognized as an internal or external command - Qt SDK - Windows
If someone already knows how to fix this, then please help me. I have been struggling to install gems and I am failing for so many days. I am wondering if ruby is so difficult.
The DOSKEY approach failed !!!
I did this - Install Mingw and installed all its developer tools and base stuff. Then added C:\MinGW\bin to environment variables to find mingw32-make.exe. Then, I ran the DOSKEY make=mingw32-make followed by the ruby command. I got the same error. I am guessing that the ruby code is spawning off a hidden cmd window and thats why the command is not working. DOSKEY is valid only in the cmd window in which you run it.
Next step - Not so nice, but, I'll change mingw32-make.exe to make.exe and see.
Failed again with a new error -
Temporarily enhancing PATH to include DevKit... Building native
extensions. This could take a while... ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb creating Makefile
make generating generator-i386-mingw32.def compiling generator.c In
file included from generator.c:1:0: ../fbuffer/fbuffer.h:5:18: fatal
error: ruby.h: No such file or directory #include "ruby.h"
^ compilation terminated. Makefile:204: recipe for target 'generator.o' failed make: *** [generator.o] Error 1
Gem files will remain installed in
C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results
logged to
C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
What do I do now ?
Most of the Ruby gems are developed for Unix and require some extra tools to make it work on Windows.
In order to install those gem in Windows, you need Ruby DEVELOPMENT KIT from the download link (choose the correct installer based on your Ruby version).
Extract the installation to some permanent location. In my system, it is C:\RubyDevKit.
Open command prompt and cd to the extracted location and execute the following commands
cd C:\RubyDevKit
ruby dk.rb init
ruby dk.rb install
devkitvars.bat
The last command is what I missed initially and took sometime to figure out. Now try installing your gem; it worked for me.
Additional Information
The Ruby Development Kit has a component called MinGW which is used to run Unix command on Windows.
The below error, in my case, was Ruby Development Kit not added to the system path variable
make
'make' is not recognized as an internal or external command,
operable program or batch file.
The command devkitvars.bat adds the Development Kit to the system path.
Try installing gnuwin-32 make and then change environment variable PATH to point to C:\Program Files (x86)\GnuWin32\bin
Ruby installation wizard asks you "Add Ruby executables to your PATH", for me, easy solution is to uninstall ruby and install again, this time checking the check box "Add Ruby executables to your PATH"
With the latest version of Ruby 2.4.2, the dev kit is included in the installation so you don't need to follow the separate install instructions. Just uninstall existing ruby and reinstall the new one here https://rubyinstaller.org/downloads/.
Once finished, it'll open up a command prompt on which you need to select option 3 to include the dev kit. However, at the time of writing it's so buggy and you may or may not have issues installing.
I have tried to setup ruby on rails on a windows system, although there are one click installers that install ruby itself and rails, many of the gems rely on a posix based operating system to be compiled, thus making it near impossible to do actual work on windows.
My advise would be to get yourself a linux system, perhaps unbuntu on your system and dual boot, or get a virtual pc software, like this one, or any of the other options, and try installing ruby from there.

Moving Sinatra from Webrick to a different server on windows - thin installed but can't load eventmachine

I'm building a simple web app on Sinatra that I can deploy like a gem to artifactory; to start with I'm getting everything setup.
Here's what I've done:
I've got the the gemspec done so I can deploy like a gem
I've got sinatra modular set up with a basic 'hello world' page
I've got Rspec setup for testing (hello world test passes)
I've got rake tasks to make things easier (booting up sinatra, building the gem, running tests, etc)
Now I need to move Sinatra from Webrick to somthing a bit more robust and that's this is where I'm hitting a wall.
I've tried Unicorn,thin and Puma but they all won't install and I don't know what to do.
They all fail at Building Native extensions, I don't know what to do.
I'm using windows 8.1 (i'd rather be doing this on ubuntu but the company uses windows and to be honest I like a challenge) ruby 2.1 and I have devkit installed (and it's working now, wouldn't last night).
From what I've read Unicorn won't work on windows so the best bet is to go with thin but that fails with: extconf.rb
checking for main() in -lc... *** extconf.rb failed ***
It mentions that I need the devkit installed (it is the first line is Temporarily enhancing PATH to include DevKit...)
Despite this it fails, I tried doing what I found in this but that didn't help ( Installing event machine didn't do anything).
I'm at a loss of what to do next.
EDIT:
Whilst I've solved the problem of getting Thin to install it now has a differant error
IT can't load eventmachine.
EDIT:
It all comes down to the fact that the Devkit wasn't being recognised or it didn't install properly or something. I wonder why.
I've tried Unicorn,thin and Puma but they all won't install and I don't know what to do. They all fail at Building Native extensions, I don't know what to do.
The reason these are failing is that many ruby gems use native C extensions which expect to be compiled and installed on a linux or unix environment.
Doing any sort of Ruby development work on a Windows machine is an exercise in sadomasochism.
I strongly recommend you install VirtualBox, download an Ubuntu or similar linux virtual machine image, boot it, configure it, and use it as your development webserver. You can continue to edit your code in windows, but you will be running it in a sane environment.
Ultimately, you may have to learn some new skills, but you will save yourself an enormous amount of frustration by moving off windows as your development platform.
I managed to get thin installed but it wasn't easy
I wiped every bit of ruby from my machine, including all references in the registry, got rid of pik as well.
I then followed these steps (that I worked out along with an answer from another question) and it now works
install rubyinstaller 2.1.3
install devkit
gem install thin --platform=[win64]
notepad C:\Ruby21-x64\lib\ruby\gems\2.1.0\gems\eventmachine-1.0.3\ext\project.h #append line 97 with //
cd C:\Ruby21-x64\lib\ruby\gems\2.1.0\gems\eventmachine-1.0.3
gem build eventmachine.gemspec
move eventmachine-1.0.3.gem up one directory
cd ..
gem install eventmachine-1.0.3.gem
del the gemfile
cd
gem install thin --platform=[win64]
A bit of a job BUT it worked,
The answer in question isthis one.
specifically
2) edited the file:
c:\Ruby21-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3\ext\project.h
and commented the line 97
//typedef int pid_t; for a more robust correction, checkout the
solution here
https://github.com/eventmachine/eventmachine/pull/450/files
3) then, i've opened command prompt, and went to the gem folder
c:\Ruby21-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3 and run:
gem build eventmachine.gemspec
In the end, after hammering my head against a wall, on a suggestion I installed chef-client and using the embedded ruby allowed it to work, that said it only uses ruby 1.9.3 but it works so for now it will have to do.

Trying to install Jekyll on Windows 8 (x64): Error installing fast-stemmer-1.0.2.gem

I'm trying to get Jekyll running on Windows 8 x64, using this manual:
Running Jekyll on Windows
I'm using the following two downloads from rubyinstaller.org:
Ruby 2.0.0-p0 (x64)
DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe
So I set up both Ruby and the DevKit according to the manual (expect it's newer versions). I tried running a little Hello World .rb script and it's working fine, path variables are set.
I then try to run gem install jekyll and I get the following output:
gem install jekyll - output on pastebin.com
The problem seems to be with the gem called fast-stemmer-1.0.2.gem, or so it seems.
Unfortunately I have practically zero experience with Ruby or Jekyll and have no idea what is going on here. Could someone please take a look at the output and send me into the right direction?
Thanks
Have you tried uninstall Ruby/DevKit and try the whole thing again, but this time, install Ruby to the default directory like C:\Ruby200-x64 instead of C:/Program Files/Ruby/Ruby200-x64
As I suspect the space in your ruby directory could be the issue. (Line 296 of your error txt)
/usr/bin/install: target
`Files/Ruby/Ruby200-x64/lib/ruby/gems/2.0.0/gems/fast-stemmer-1.0.2/lib'
is not a directory make: *** [install-so] Error 1
Also quote from Issues installing Ruby and Rails and DevKit on windows 7 x64 - fix needed
Seems you installed Ruby (along the DevKit?) inside a directory with
spaces.
As indicated during Ruby own installer, path with spaces are not
recommended (that is why default is C:\Ruby193
GCC, the compiler that is part of DevKit, has problems with path with
spaces, so installation of DevKit is also recommended to be placed in
a path without spaces (e.g. C:\DevKit)

Resources