问题
I tried to install Nokogiri on my Ubuntu 12.04 system, and got an error that said "libxslt is missing
", but the libxslt-dev
and libxml2-dev
are installed.
Is there a robust installation process? How can I check the links to dependent libraries?
I used RVM, and the RVM pkg is installed too.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/home/victor/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... no
-----
libxslt 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
--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/victor/.rvm/rubies/ruby-1.9.3-p125/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
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-libiconv-config
--without-libiconv-config
--with-xml2lib
--without-xml2lib
--with-xsltlib
--without-xsltlib
Gem files will remain installed in /home/victor/.rvm/gems/ruby-1.9.3-p125@dradis/gems/nokogiri-1.5.4 for inspection.
Results logged to /home/victor/.rvm/gems/ruby-1.9.3-p125@dradis/gems/nokogiri-1.5.4/ext/nokogiri/gem_make.out
enter code here
回答1:
I have also experienced the same problem with rvm, even though I had done the following, as per documentation:
sudo apt-get install libxslt-dev libxml2-dev
rvm pkg libxml2
andrvm pkg libxslt
The only way I could get this solved was, after a lengthy investigation:
- Uninstall the ruby installation:
rvm remove 1.9.3
- Delete all
libxslt*
andlibxml2*
libs from~/.rvm/usr/lib
if you had previously donervm pkg ...
- Reinstall ruby:
rvm install 1.9.3
Reinstalling after the apt-get
commands seems to be the only way of getting this to work. Also, ensuring the libs installed with rvm pkg
don’t interfere helped.
When everything else fails...
If everything else fails and you absolutely need the gem installed, you can also rebuild nokogiri
by applying a simple patch — provided that you have all build tools installed, and with the caveat that this will install the latest and potentially unstable code:
git clone git://github.com/sparklemotion/nokogiri
- get patch from this gist and save it as
x86_64.patch
in thenokogiri
folder. - Apply patch:
patch -p1 < x86_64.patch
- Rebuild:
rake native gem
— this should build the gem in thepkg/
folder - Install the gem using
gem install pkg/nokogiri-<version>-x86_64-linux.gem
回答2:
I'm pretty new to ruby, but this...
gem install nokogiri -v '1.5.2' -- --with-xml2-lib=/usr/lib/i386-linux-gnu --with-xml2-include=/usr/include/libxml2 --with-xslt-lib=/usr/lib/i386-linux-gnu --with-xslt-include=/usr/include/libxslt
...worked for me on Ubuntu 12.04. (Or, anyway, it satisfied the nokogiri dependency and got me one step closer to what I'm really trying to accomplish.) I thought it might have messed up my RVM magic, but nokogirl-1.5.2 is definitely sitting there in ~/.rvm/ruby-1.9.3-p194/gems, so...maybe it's all good?
回答3:
I was having this issue on Ubuntu 13.04.
I had tried everything that you find all over the place online. Making sure packages listed on the Nokogiri install page are present, etc etc.
The only thing that eventually did it for me was installing libsxlt from source. After that everything worked perfectly.
回答4:
I had to use gem install nokogiri -- --with-iconv-dir=/usr/lib/ruby/1.9.1/x86_64-linux
回答5:
sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8
sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby
sudo apt-get install libxslt-dev libxml2-dev
?
来源:https://stackoverflow.com/questions/11022701/what-is-a-robust-installation-process-for-nokogiri-on-ubuntu