我正在使用 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
怎么了?
答案1
IIRC,mkmf
在ruby-dev
包装中:
rvm install 1.9.1-dev
手动安装sudo apt-get install ruby1.9.1-dev
(取决于您的版本)。
答案2
我按照这个博客的步骤操作。很有帮助。 http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/
最后,你需要通过告诉 Rubygems 不要在本地安装每个包的文档来释放空间,运行:echo "gem: --no-ri --no-rdoc" > ~/.gemrc