我尝试rails
按照安装本指南,当我这样做时,出现此错误:
$ sudo gem install rails
WARNING: Error fetching data: Errno::ENOENT: No such file or directory - getaddrinfo (http://rubygems.org/specs.4.8.gz)
WARNING: Error fetching data: Errno::ENOENT: No such file or directory - getaddrinfo (http://rubygems.org/latest_specs.4.8.gz)
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.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json- 1.8.0/ext/json/ext/generator/gem_make.out
我以前从未见过这样的事情,因此非常感谢任何反馈。
答案1
尝试重新安装 Ruby,然后安装 Gem,最后安装 Rails。问题可能出在 Ruby 或 Gem 上。
答案2
尝试使用rvm
或rbenv
;它们都很好用...我个人更喜欢 rvm,因为我想将 gem-sets 分开用于不同的项目。请参阅 rbenv 存储库如果你想使用一个 ruby 版本进行简单安装。我写了一篇博客文章Rbenv 安装
安装 rbenv
设置:
sudo apt-get update sudo apt-get upgrade -y
安装 Ruby 和其他依赖项所需的组件。
sudo apt-get install git-core -y sudo apt-get install curl -y 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 libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev git clone git://github.com/sstephenson/rbenv.git ~/.rbenv echo ‘export PATH="$HOME/.rbenv/bin:$PATH"’ >> ~/.profile echo ‘eval "$(rbenv init -)"’ >> ~/.profile
(注意:根据需要修改 .bash_profile , .bash_login 或 .zshrc 。)
现在安装一些所需的 rbenv 插件。
cd ~/.rbenv/ mkdir plugins cd ~/.rbenv/plugins git clone git://github.com/sstephenson/ruby-build.git
重启终端。
安装 Ruby
rbenv install 1.9.3-p385
设置您的全局 Ruby 版本。
rbenv global 1.9.3-p385 rbenv rehash ruby -v
安装 Ruby on Rails 框架
gem install bundler gem install rails
(不要惊慌,安装导轨需要一些时间。)