0

I've installed nokogiri using the "gem install nokogiri" command in git bash and shows me the gem has installed successfully. But when I try to run rails s it gives me the require error for nokogiri. I am not sure what's the reason and how to solve it.

I am using windows 10

I am using Ruby 2.2.3

Installing nokogiri

enter image description here

Error that I get

enter image description here

Mj1992
  • 3,404
  • 13
  • 63
  • 102
  • Did you try to force nokogiri to install using system libs? e.g. `gem install nokogiri --use-system-libraries` – trh Oct 03 '15 at 18:06
  • it's giving `invalid option --use-system-libraries`. I am using windows 10 – Mj1992 Oct 03 '15 at 18:30

2 Answers2

1

I'm afraid nokogiri won't work for the combination of Ruby 2.2 and mingw. According to https://github.com/sparklemotion/nokogiri/issues/1256, it is currently only supported for Ruby 1.9, 2.0 and 2.1.

There is a workaround with manual install of libraries, as described in RubyInstaller 2.2.1 and Rails - Rake cannot load Nokogiri, but it seems to be a bit tricky. So if Ruby 2.2 is not that critical for you, you may want to downgrade to Ruby 2.1.

And as a general recommendation -- development on Ruby/Rails using Windows it not really optimal, consider switching to Linux

Community
  • 1
  • 1
The Ancient
  • 382
  • 3
  • 13
  • The first part answer is technically correct, albeit the last part doesn't make it seem like a very welcoming community, when `Nokogiri 1.6.7` is released, which should be pretty soon, it will be fixed so that you don't you can compile nokogiri on Windows. Which will fix problems like these where the binary isn't included and the gem won't compile natively on Windows. – Azolo Oct 06 '15 at 00:24
  • Fair enough. Still, if you are talking about development on Windows, I'm just sharing my own experience. It tried developing on Windows, but two years ago switched to Linux as a development platform and, I must admit, it makes many things much simpler. Starting from the fact that I do not rely on RubyInstaller anymore (which has a significant delay in version adoption), down to significant simplification of workflows, concerning native gems, which are much more straightforward in Linux. What you wrote, @Azolo, is definitely correct wrt Nokogiri, but there are many others around... – The Ancient Oct 06 '15 at 07:53
0

I also faced similar issue with nokogiri. This fixed nokogiri issue for me on ruby 2.2:

sudo apt-get install libxslt-dev libxml2-dev

and then

sudo gem install nokogiri

Hope this helps.

Avi
  • 391
  • 2
  • 3
  • 20