
Fix
- Package installation (receives Nokogiri files)
- Go to
ruby_dir\lib\ruby\gems\2.2.0\gems\nokogiri-1.6.6.2\ext\nokogiri - Open
extconf.rb - Add
dir_config('iconv').any? or pkg_config('libiconv') dir_config('iconv').any? or pkg_config('libiconv') in #376 - Download
MinGW64 and MSYS folders from Mega - Add them to your
PATH on Windows (remove Devkit path refs - it doesn't work) - Download
libxml2 , libxslt , iconv libraries (or here ) - Run
ruby extconf.rb --platform=ruby --n --use-system-libraries link to loaded libraries - Run
make - Run
make install
Actions
Package installation
The first step is bundle.
This will put the nokogiri on your computer without launching the pre-packaged compiler (which basically does not work on Windows).
This will show the Nokogiri as installed:

Overview
Go to the nokogiri folder to find ext/nokogiri/extconf.rb :

Open extconf.rb
... and add dir_config('iconv').any? or pkg_config('libiconv') dir_config('iconv').any? or pkg_config('libiconv') in #376

The standard Nokogiri sets "rely" on libxml2 include iconv - we need to explicitly define it, otherwise iconv.h is missing errors will occur.
Add Toolchain
Do not use Devkit for this - it does not work.
You need MinGW :

I copied my exact MinGW64 and MSYS64 folders to Mega (key !FJtcq25l-QMsNltCxllMhc1IGqORvap8xv8gWxSUbDA ):

Add to PATH
This gives access to gcc and make (both required):

Remove the Devkit link from your path and add the following:
- MINGW64_PATH / bin
- MSYS64_PATH / bin
Download Libs
I added libraries to Mega:

You will unpack them here:

All libraries from this source .
Run extconf.rb
Once the libs libraries are on your system, you can run ruby extconf.rb to configure the build:

32bit
ruby extconf.rb --platform=ruby -N -- --use-system-libraries --with-xml2-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxml2-2.9.2-win32-x86 --with-xml2-include=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxml2-2.9.2-win32-x86/include/libxml2 --with-iconv-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/iconv-1.14-win32-x86 --with-xslt-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxslt-1.1.28-win32-x86
64bit
#64 ruby extconf.rb --platform=ruby -N -- --use-system-libraries --with-xml2-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxml2-2.9.2-win32-x86_64 --with-xml2-include=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxml2-2.9.2-win32-x86_64/include/libxml2 --with-iconv-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/iconv-1.14-win32-x86_64 --with-xslt-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxslt-1.1.28-win32-x86_64
make

This can lead to errors / warnings if it says β Error 1 (ignored) β, this should be fine.
After that use make install :

Then go to install Rails and run rails s :

Explanation
To give context:
Ruby 2.2+ on Windows does not compile the extensions required by Nokogiri.
Gem extensions are additional dependencies (libraries) that it uses.
They are created when installing a gem:

Extensions
The absence of extensions prevents Nokogiri from starting.
Extensions exist in the gem ext folder ( you can read about them here ):

Mysql2 , RMagick , PGSQL , nokogiri , etc. all use extensions / libraries.
That's why - on Windows - when installing the gem, you should use special switches ( --with-opt-dir ). This gives Ruby / shell / ( cmd ) the required lib / include directories needed to build the gem files (this is equivalent to how PATH works.)
On Linux / Mac these directories are managed using the appropriate package managers ( brew / apt-get ). Windows does not, so you need to install extensions manually.
Since Windows does not have a standard set of libraries, you must download them yourself. You must also create them yourself (which is difficult).
Fix for installing Nokogiri - using the right libraries and creating tools for installing gem.
Build
The difference with Ruby 2.2+ is that the gem will βinstallβ without showing any exceptions. You think that it is installed, only to find Rails, it does not load (hence the error nokogiri/nokogiri.so ).
This means that you must make sure that you have the files in your system and run the compiler to install them.
The above documentation should show how to do this.