运行bundle install时出现Nokogiri错误

wik*_*hen 20 ruby rubygems ruby-on-rails nokogiri rbenv

试图让克隆的Rails应用程序运行.运行时bundle install我收到此错误:

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.
Run Code Online (Sandbox Code Playgroud)

但这是输出rbenv version:

› rbenv version
1.9.3-p429 (set by /Users/andrewguo/.rbenv/version)
Run Code Online (Sandbox Code Playgroud)

跑步时gem list我得到:

.
.
.
mini_portile (0.5.0)
minitest (2.5.1)
multi_json (1.7.7)
nokogiri (1.6.0)
Run Code Online (Sandbox Code Playgroud)

我已经绞尽脑汁一小时了,现在试图找出可能出错的地方......请帮助!

编辑:

这是一个更详细的错误输出:

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
Run Code Online (Sandbox Code Playgroud)

小智 27

我正在使用Mac OSX(El Capitan),它似乎与Xcode Developer Tools有关.我跑进xcode-select --install了我的工作目录,然后重新bundle install命令,在^^之后一切正常.

希望这可以帮助某人.


Phi*_*hil 18

我遇到了这个错误,这对我有用:

bundle config build.nokogiri --use-system-libraries
bundle install
Run Code Online (Sandbox Code Playgroud)

问题在于libxml:

libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
Run Code Online (Sandbox Code Playgroud)


wik*_*hen 12

原来我使用的是默认系统Ruby(因此安装了所有的宝石/Library/Ruby/Gems),尽管rbenv指向ruby-1.9.3,这就是Nokogiri抱怨的原因.

通过将此添加到$ PATH来修复此问题,因此rbenv在系统ruby之前加载:

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


Emm*_*uel 11

确保您拥有最新版本的命令行工具.如果你不确定只是运行xcode-select --install,这将弹出一个很好的gui来指导你完成安装过程.您也可以检查mac app store以查看是否有等待您的更新.目前的版本是Command Line Developer Tool for OS X 10.10如此,你可以看到Yosemite是否没有遇到问题.获得更新后,运行sudo bundle install,您可以拥有最新版本的nokogiri.祝好运.


小智 5

尝试使用旧版本的nokogiri,它对我有用

gem'nokogiri','1.5.9'


小智 5

以下对我有用:

gem install nokogiri -- --use-system-libraries
Run Code Online (Sandbox Code Playgroud)