Ubuntu上的Rails安装失败,“无法加载此类文件 - mkmf”

时间:2012-10-04 16:43:04

标签: ruby-on-rails ruby

在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

3 个答案:

答案 0 :(得分:75)

如果我没弄错的话,mkmf是ruby-dev软件包的一部分。尝试:

sudo aptitude install ruby1.9.1-dev

当然,最好通过RVM安装ruby:)

答案 1 :(得分:66)

对于ubuntu 13.04,这对我有用:

sudo apt-get install ruby-dev

答案 2 :(得分:-1)

试     rvm all do gem install nokogiri