我正在尝试在我的本地计算机上安装Ruby on Rails用于开发目的,但我遇到了一个错误。我不能说,但似乎它可能是一个宝石错误。虽然,这是我第一次尝试使用Ruby,Gem和Rails这三个,所以我不确定。
运行命令“sudo gem install rails -V”这些是在命中错误后打印的最后几行:
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:13:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/atomic-1.1.14 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/atomic-1.1.14/ext/gem_make.out
安装的Ruby版本是:
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
gem的版本是:
1.8.23
答案 0 :(得分:2)
以普通用户身份安装gem,而不是sudo:
gem install rails
或者安装ruby dev包。 SO中有很多类似的答案:
Failed to build gem native extension — Rails install
Failed to build gem native extension (mkmf (LoadError)) - Ubuntu 12.04
答案 1 :(得分:1)
来自atomic
gem README。
As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use the new atomic
请安装Java,然后重新运行gem install过程。
答案 2 :(得分:1)
你有什么Linux?
在Mint,我做了:
sudo apt-get install git
sudo apt-get install curl
curl -L https://get.rvm.io | bash -s stable --ruby
sudo apt-get install git-core
source ~/.rvm/scripts/rvm
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
rvm autolibs enable
rvm reload
rvm requirements
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
rvm install ruby-2.0
curl -L https://get.rvm.io | bash -s stable --rails
它工作正常。这将(当前)安装Ruby 2.0和rails 4.0。