Ruby-on-rails 使用 rails 3.1.0 和 ubuntu 安装 Nokogiri 1.5.0 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8003523/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error installing Nokogiri 1.5.0 with rails 3.1.0 and ubuntu
提问by user938363
Here is the error running bundle install vendor/gems on server:
这是在服务器上运行 bundle install vendor/gems 的错误:
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?
有什么想法吗?
回答by Dylan Markow
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 requirementsto see the exact list. Right now, that list is:
您需要在您的机器上安装所有必要的库。当您安装 RVM 时,它应该已经为您列出了。在当前版本的 rvm 上,您可以运行rvm requirements以查看确切列表。现在,该列表是:
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
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
回答by jimnah
You are missing some packages. Try running this (Linux only):
您缺少一些软件包。尝试运行这个(仅限 Linux):
$ sudo apt-get install libxslt-dev libxml2-dev
回答by ipd
You need to install libxml2.
您需要安装 libxml2。
On Mac OS, using homebrew, this will be:
在 Mac OS 上,使用自制软件,这将是:
brew install libxml2
回答by Laxman More
It looks like a gem dependency error.
它看起来像一个 gem 依赖错误。
You need to run the bundle updatecommand. It will resolve dependencies:
您需要运行该bundle update命令。它将解决依赖关系:
bundle update
回答by user3786185
Just do this:
只需这样做:
sudo apt-get install libxslt-dev libxml2-dev libxml2
then type this in terminal (linux) / cmd(windows):
然后在终端(linux)/cmd(windows)中输入:
export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
回答by agstwn21
Try this one if others doesn't work, its really work on me. Devtools for CentOS
如果其他人不起作用,请尝试这个,它真的对我有用。CentOS 开发工具
回答by Darex1991
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
回答by shilovk
For Ubuntu:
对于 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:
对于 MacOS:
brew install libxml2
gem install nokogiri -v '1.8.2' -- --use-system-libraries \
--with-xml2-include=$(brew --prefix libxml2)/include/libxml2

