I think I got it working on my system:
I don’t know what was done to get this working, but I’ll share what I did:
-
The problem for Windows with
Ruby 2.2+
&Nokogiri
is that the gem doesn’t compile. Nokogiri requireslibXML
,libxslt
&libiconv
in order for it to work. These are nominally compiled atgem install
, but for whatever reason, this does not occur inRuby 2.2+
. -
Therefore, in order to install the gem (this is exactly the same situation with
mysql2
andrmagick
), you need the system dependencies (mentioned above). -
From
Ruby 2.2+
, it seems that gems will “install” even if they don’t have their dependencies on the system (as opposed to refusing the install by not building native extensions in previous versions). The new runtime errors which appear includecannot load such file -- mysql2/2.2/mysql2 (LoadError)
and the corresponding one fornokogiri
(cannot load such file -- nokogiri/nokogiri
). -
With this in mind, you have to appreciate how the gems are installed & work. A good example is the
mysql2
gem – to install it, you need to download the MYSQL C-Connector plugin and then link to the dependency with the following code:gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector-path"'
-
With
Nokogiri
, you need to havelibxml
,libiconv
andlibxslt
on your system. I learnt that from this post:
-
The problem arises here.
I am not 100% sure what I did here to get this working (even temporarily). I know that I installed the Nokogiri gem, and then set about compiling the gem usingruby extconf.rb
(which is what the gem does anyway). Considering this what I feel worked, I’ll explain how this was performed. -
The gem will typically download the libraries through install. It keeps these in the
ext/tmp/ports
folder. For my system, the download oflibiconv
was what prevented the install from completing (error aboutCPPFLAGS
). With this in mind, I figured that if the gem installed, and if it was trying to build, it would be prudent to get the dependencies installed. -
Thus, I worked on the
ruby ext/extconf.rb
process using the--use-system-libraries
switch:
"...\nokogiri>ruby extconf.rb --platform=ruby -N --use-system-libraries --w
ith-xml2-dir=C:\Users\Richard\Downloads\Ruby\libxml2-2.7.8.win32 --with-xml2-include=C:\Users
\Richard\Downloads\Ruby\libxml2-2.7.8.win32\include --with-xml2-lib=C:\Users\Ric
hard\Downloads\Ruby\libxml2-2.7.8.win32\lib --with-iconv-dir=C:\Users\Richard\Do
wnloads\Ruby\iconv-1.9.2.win32 --with-iconv-include=C:\Users\Richard\Downloads\R
uby\iconv-1.9.2.win32\include --with-iconv-lib=C:\Users\Richard\Downloads\Ruby\i
conv-1.9.2.win32\lib --with-zlib-dir=C:\Users\Richard\Downloads\Ruby\zlib-1.2.5"
I coupled this with downloading the aforementioned libraries (and some which didn’t work):
-
I don’t have a record of the output of the above command, but I am pretty sure it built the extensions as required, ending in saying a “Makefile” had been compiled. When a
Makefile
is available, you should be able to usenmake
(Windows 7.1 SDK) ormake
(MingW) to get it to run. I did this, and it seemed to work. -
I tried loading the server today, and it appeared to work.
That’s the best I have right now.
I am available to answer comments etc as required.