我正在使用 Ubuntu 14.04。我想用最新的ruby(2.1.3版),所以用RVM安装。
rvm install ruby --latest
rvm use ruby --latest --default
但是当我尝试安装 Rails 时,出现以下错误:
vagrant@vagrant-ubuntu-trusty-64:~$ sudo gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
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:1:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
怎么了?
IIRC,
mkmf
在ruby-dev
包装中:手动安装
sudo apt-get install ruby1.9.1-dev
(取决于您的版本)。我遵循了这个博客中的步骤。这很有帮助。 http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/
最后,您需要通过告诉 Rubygems 不要在本地安装每个包的文档来释放空间,运行:echo "gem: --no-ri --no-rdoc" > ~/.gemrc