nokogiri不会安装 - 错误:无法构建gem原生扩展

时间:2013-04-16 02:56:01

标签: ruby gem nokogiri

在ubuntu 12.04上,我得到以下内容。

sudo apt-get install libxml2 libxml2-dev libxslt libxslt-dev
sudo gem install nokogiri
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    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 /var/lib/gems/1.9.1/gems/nokogiri-1.5.9 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.5.9/ext/nokogiri/gem_make.out

这是我的ruby版本

ruby --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

我正在尝试安装使用knife-ec2作为厨师。

1 个答案:

答案 0 :(得分:47)

您应该拥有必要的所需包裹:

<强>红宝石

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

nokogiri

sudo apt-get install libxslt-dev libxml2-dev zlib1g-dev
sudo gem install nokogiri

这应该解决这个问题。或者,请参阅Problems installing Nokogiri (1.5.2) on Ubuntu 12.10哪些人也应该能够回答您的问题。指针供将来参考。尝试研究stackoverflow或其他可能有答案的资源,因为您可能会发现问题已经解决 无线