Nokogiri error when running bundle install
Asked Answered
P

10

23

Trying to get a cloned Rails app running. When running bundle install I get this error:

Using mini_portile (0.5.0)
Installing nokogiri (1.6.0)
Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.

But this is the output for rbenv version:

› rbenv version
1.9.3-p429 (set by /Users/andrewguo/.rbenv/version)

When running gem list I get:

.
.
.
mini_portile (0.5.0)
minitest (2.5.1)
multi_json (1.7.7)
nokogiri (1.6.0)

I've been racking my brain for an hour now trying to figure out what can possibly be wrong... Please help!

Edit:

Here's a more verbose error output:

An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.
Bundler::InstallError: An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/installer.rb:130:in `install_gem_from_spec'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/installer.rb:91:in `run'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/installer.rb:90:in `run'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `__send__'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/bin/bundle:20
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/bin/bundle:20
/usr/bin/bundle:19:in `load'
/usr/bin/bundle:19
Photobathic answered 20/6, 2013 at 1:58 Comment(0)
P
11

Turned out I was using the default system Ruby (and thus installing all the gems there in /Library/Ruby/Gems) even though rbenv points to ruby-1.9.3 so that's why Nokogiri was complaining.

Fixed this by adding this to $PATH, so rbenv loads before the system ruby:

export PATH="$HOME/.rbenv/bin:$PATH"

Photobathic answered 20/6, 2013 at 2:30 Comment(0)
F
28

I'm using Mac OSX (El Capitan) and it appears to be related to Xcode Developer Tools. I ran xcode-select --install in my working directory, then reran bundle install command and it all worked fine after that ^^.

Hope this could help someone.

Fushih answered 17/11, 2015 at 14:54 Comment(0)
A
23

I ran into this error and this is what worked for me:

bundle config build.nokogiri --use-system-libraries
bundle install

The problem was with libxml:

libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
Agee answered 13/11, 2014 at 2:9 Comment(1)
Next worked for me: sudo gem install nokogiri -v '1.6.6.2' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/libVasilikivasilis
P
11

Turned out I was using the default system Ruby (and thus installing all the gems there in /Library/Ruby/Gems) even though rbenv points to ruby-1.9.3 so that's why Nokogiri was complaining.

Fixed this by adding this to $PATH, so rbenv loads before the system ruby:

export PATH="$HOME/.rbenv/bin:$PATH"

Photobathic answered 20/6, 2013 at 2:30 Comment(0)
T
11

make sure you have the latest version of command line tools. if you're not sure just run xcode-select --install and this will pop up a nice gui to guide you through the installation process. you can alternatively check the mac app store to see if you have an update there waiting for you. the current version is Command Line Developer Tool for OS X 10.10 so you can see if Yosemite hasn't got a problem with that. after getting the update, run sudo bundle install and you can have the latest version of nokogiri. good luck.

Touchstone answered 8/11, 2014 at 1:55 Comment(0)
A
5

Try using an older version of nokogiri, it worked for me

gem 'nokogiri', '1.5.9'

Akins answered 20/6, 2013 at 2:12 Comment(1)
how to use ? write at file gem ?Chivers
C
5

The following worked for me:

gem install nokogiri -- --use-system-libraries
Cardiganshire answered 22/9, 2015 at 2:54 Comment(0)
K
2

If fellow googler is using linux (ubuntu) then installing deb package zlib1g-dev helped

Kalikow answered 20/9, 2015 at 0:47 Comment(0)
C
1

Install older version with this command:gem install nokogiri -v 1.5.5

Camara answered 7/1, 2014 at 20:14 Comment(0)
G
1

On an Ubuntu machine these are the documentation suggestions for installing Nokogiri:

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
gem install nokogiri

https://nokogiri.org/tutorials/installing_nokogiri.html

I also had to: sudo apt-get install libxslt-dev libxml2-dev as explained in this so post: https://mcmap.net/q/150825/-nokogiri-installation-fails-libxml2-is-missing

Grampus answered 8/11, 2020 at 23:23 Comment(0)
C
0

You just need to install Homebrew in your macOS

Run on terminal /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Conservative answered 5/4, 2019 at 1:21 Comment(2)
please elaborateEamon
Can you explain that further? How does installing Homebrew solve the given problems?Quota

© 2022 - 2024 — McMap. All rights reserved.