Ruby-on-rails Rails 在 Ubuntu 上安装失败,“无法加载此类文件 -- mkmf”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12731904/
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
Rails installation failed on Ubuntu with "cannot load such file -- mkmf"
提问by user1720731
I have this problem while installing Rails on Ubuntu 11:
我在 Ubuntu 11 上安装 Rails 时遇到了这个问题:
root@salah:/home/salah/rubygems-1.8.15# sudo gem install mysql
Fetching: mysql-2.8.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:10:in `<main>'
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
回答by Peter Duijnstee
mkmf is part of the ruby-dev package if I'm not mistaken. Try:
如果我没记错的话,mkmf 是 ruby-dev 软件包的一部分。尝试:
sudo aptitude install ruby1.9.1-dev
Of course you may be better off installing ruby through RVM :)
当然,您最好通过 RVM 安装 ruby :)
回答by edelans
For ubuntu 13.04, this is what worked for me:
对于 ubuntu 13.04,这对我有用:
sudo apt-get install ruby-dev
回答by Darren Cato
try
rvm all do gem install nokogiri
尝试
rvm all do gem install nokogiri

