Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'require': cannot load such file -- 'nokogiri\nokogiri' (LoadError) when running `rails server`

I'm running a clean install of Ruby 2.2.1 on Windows 8.1 with DevKit. After the installation I run:

gem install rails rails new testapp cd testapp rails server 

leaving everything else at default.

The process fails at the last line when, instead of running the server, I get the error message

in 'require': cannot load such file -- 'nokogiri\nokogiri' (LoadError) 

It happens every time and I've looked around and tried everything I found to fix it, but nothing so far has worked.

What is the problem here and how do I get a simple test Rails app to work?

like image 301
Shef Avatar asked Mar 12 '15 00:03

Shef


2 Answers

  1. First, uninstall the version of Nokogiri you currently have with:

    gem uninstall nokogiri 
  2. Download Nokogiri 1.6.6.2 (x64) or Nokogiri 1.6.6.2 (x86)

  3. Install this version locally using:

    gem install --local C:\Users\$user$\Downloads\nokogiri-1.6.6.2-x64-mingw32.gem 

    or if you're running 32bit Ruby:

    gem install --local C:\Users\$user$\Downloads\nokogiri-1.6.6.2-x86-mingw32.gem 

    The path may differ depending on where you downloaded the file to.

Try to start the server again using ruby bin\rails server, and it should work.

like image 26
Thant Shwe Aung Avatar answered Oct 06 '22 07:10

Thant Shwe Aung


Nokogiri doesn't support Ruby 2.2 on Windows yet. The next release will. See https://github.com/sparklemotion/nokogiri/issues/1256

Nokogiri doesn't support native builds (e.g. with devkit) on Windows. Instead it provides gems containing prebuilt DLLs.

There's a discussion which you may want to join or watch on the topic of devkit build support here: https://github.com/sparklemotion/nokogiri/issues/1190

like image 126
Mike Dalessio Avatar answered Oct 06 '22 07:10

Mike Dalessio