37

Here is the error running bundle install vendor/gems on server:

Installing nokogiri (1.5.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/dtt/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/home/dtt/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --with-iconv-dir
        --without-iconv-dir
        --with-iconv-include
        --without-iconv-include=${iconv-dir}/include
        --with-iconv-lib
        --without-iconv-lib=${iconv-dir}/lib
        --with-xml2-dir
        --without-xml2-dir
        --with-xml2-include
        --without-xml2-include=${xml2-dir}/include
        --with-xml2-lib
        --without-xml2-lib=${xml2-dir}/lib
        --with-xslt-dir
        --without-xslt-dir
        --with-xslt-include
        --without-xslt-include=${xslt-dir}/include
        --with-xslt-lib
        --without-xslt-lib=${xslt-dir}/lib


Gem files will remain installed in /vol/www/emclab/releases/20111104001151/vendor/gems/ruby/1.9.1/gems/nokogiri-1.5.0 for inspection.
Results logged to /vol/www/emclab/releases/20111104001151/vendor/gems/ruby/1.9.1/gems/nokogiri-1.5.0/ext/nokogiri/gem_make.out
An error occured while installing nokogiri (1.5.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.0'` succeeds before bundling.

You can skip this part. The error message is pretty much self explanatory, but the website requires a few more words explaining the code.

Any thoughts?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
user938363
  • 9,990
  • 38
  • 137
  • 303

8 Answers8

64

You need to have all the necessary libraries installed on your machine. When you installed RVM , it should have listed this for you. On the current version of rvm, you can run rvm requirements to see the exact list. Right now, that list is:

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

Dylan Markow
  • 123,080
  • 26
  • 284
  • 201
25

You are missing some packages. Try running this (Linux only):

$ sudo apt-get install libxslt-dev libxml2-dev
Linuxios
  • 34,849
  • 13
  • 91
  • 116
jimnah
  • 259
  • 3
  • 2
6

It looks like a gem dependency error.

You need to run the bundle update command. It will resolve dependencies:

bundle update
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Laxman More
  • 307
  • 1
  • 5
  • 14
5

You need to install libxml2.

On Mac OS, using homebrew, this will be:

brew install libxml2

See http://nokogiri.org/tutorials/installing_nokogiri.html.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
ipd
  • 5,674
  • 3
  • 34
  • 49
4

Just do this:

sudo apt-get install libxslt-dev libxml2-dev libxml2

then type this in terminal (linux) / cmd(windows):

export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
  • 2
    `export NOKOGIRI_USE_SYSTEM_LIBRARIES=true` worked for me on Ubuntu. Thanks! I think while installing nokogiri, using the `--use-system-libraries` flag will have the same effect. But if you're using `bundle install` on some `Gemfile` I guess the best way is to set that config option. – basicallydan Feb 01 '15 at 10:32
0

Try this one if others doesn't work, its really work on me. Devtools for CentOS

agstwn21
  • 123
  • 1
  • 14
  • Instead of posting a link, summarize WHAT on that page helped. Links rot, so when this does the answer will be of no value. – the Tin Man Nov 19 '15 at 23:36
0

When I used this code I got another error:

ERROR:  Error installing disposable:
    invalid gem: package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodError) in /home/admin/.rvm/gems/ruby-2.1.3@lol/cache/nokogiri-1.6.4.1.gem

I tried many different solutions, but helped med:

$ rm /home/admin/.rvm/gems/ruby-2.1.3@lol/cache/nokogiri-1.6.4.1.gem
$ gem update
$ gem install nokogiri

Other commands that can help:

sudo apt-get install synaptic
sudo apt-get update
sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui
sudo apt-get install build-essential
sudo apt-get install "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Darex1991
  • 855
  • 1
  • 10
  • 24
0

For Ubuntu:

sudo apt-get install libxml2 libxml2-dev libxslt-dev zlib1g-dev
sudo gem install nokogiri -v '1.8.2' -- --use-system-libraries 

For MacOS:

brew install libxml2
gem install nokogiri -v '1.8.2' -- --use-system-libraries \
  --with-xml2-include=$(brew --prefix libxml2)/include/libxml2
shilovk
  • 11,718
  • 17
  • 75
  • 74