Rails教程:捆绑安装时出现nokogiri-1.5.2错误

时间:2012-05-05 22:40:05

标签: ruby-on-rails rubygems nokogiri railstutorial.org

完成Ruby on Rails Tutorial第3章的RVM设置,rspec和保护部分之后,每当我运行bundle install时,我都会收到以下错误转储:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby1.9.1 extconf.rb 
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `<main>'


Gem files will remain installed in /home/dan/.bundler/tmp/17577/gems/nokogiri-1.5.2 for inspection.
Results logged to /home/dan/.bundler/tmp/17577/gems/nokogiri-1.5.2/ext/nokogiri/gem_make.out
An error occured while installing nokogiri (1.5.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.2'` succeeds before bundling.

在gem_make.out中:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby1.9.1 extconf.rb 
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file --mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `<main>'

我已经调试了一段时间了,我想我已经卡住了。非常感谢帮助!

1 个答案:

答案 0 :(得分:79)

您需要头文件来编译Ruby的扩展模块。

您可以使用以下命令获取适用于您的ruby版本的正确版本:

sudo aptitude install ruby-dev