使用 RVM 在 Ubuntu 上安装 Rails Path [英] Installing Rails Path on Ubuntu with RVM
问题描述
我是运行 Ubuntu 10.04 并尝试安装 Rails 的 Linux 菜鸟.我先安装ruby,然后安装RVM,然后下载安装rubygems,然后安装rails.
I'm a linux noob running Ubuntu 10.04 and trying to install rails. I first installed ruby and then RVM and then downloaded and installed rubygems and then installed rails.
Rails 似乎只有在命令前面有一个sudo"时才会响应.如果我在终端中编写rails new test",我会得到这个:
Rails only seems to respond if I have a 'sudo' in front of the command. If I write 'rails new test' in the terminal I get this:
/usr/local/lib/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:214:in `activate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
如果我去终端并写rails -v",我会得到同样的结果:
If I go to the terminal and write 'rails -v' I get the same thing:
/usr/local/lib/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:214:in `activate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
如果我去终端写sudo rails -v",我会得到以下信息:Rails 3.0.0.rc
And if I go to the terminal and write 'sudo rails -v' I get the following: Rails 3.0.0.rc
'gem environment' 给了我这个:
'gem environment' gives me this:
RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-07-11 patchlevel -1) [i686-linux]
- INSTALLATION DIRECTORY: /home/josh/.rvm/gems/ruby-1.9.2-rc2@rails3tutorial
- RUBY EXECUTABLE: /home/josh/.rvm/rubies/ruby-1.9.2-rc2/bin/ruby
- EXECUTABLE DIRECTORY: /home/josh/.rvm/gems/ruby-1.9.2-rc2@rails3tutorial/bin
我怀疑我的路径设置不正确,但我不确定如何修复它.建议?
My suspicion is that my path is not set up correctly but I'm not sure how to fix it. Suggestions?
推荐答案
我在全新安装 Ubuntu 10.10 时也遇到了这个问题……即使在安装了$ rvm notes"记录的 rvm 和 ruby 先决条件之后.
I also experienced this problem on a clean install of Ubuntu 10.10...even after installing the rvm and ruby pre-requisites documented by "$ rvm notes".
似乎是rvm"gem安装无法找到系统zlib安装的问题.上面丹尼尔的评论是一个很好的评论 - 遗憾的是它没有被列为答案.
It appears to be a problem with the "rvm" gem installation being unable to find the system zlib installation. Daniel's comment above is a great comment - a pity it is not listed as an answer.
所以我的解决方案是按照丹尼尔指出的说明进行操作:https://rvm.beginrescueend.com/包/zlib/.
So the solution for me was to follow the instructions pointed out by Daniel at: https://rvm.beginrescueend.com/packages/zlib/.
$ rvm pkg install zlib
$ rvm remove 1.9.2
$ rvm install 1.9.2
第一个命令在本地将 zlib 安装到您的 rvm 区域.第二个命令删除 ruby 1.9.2,第三个命令使用 rvm-local zlib 重新安装 ruby 1.9.2.
The first command install zlib locally into your rvm area. The second command removes ruby 1.9.2 and the third command reinstalls ruby 1.9.2 with the rvm-local zlib.
然后设置您的 ruby 版本并安装 gems:
Thereafter set your ruby version and install gems:
$ rvm 使用 1.9.2
$ gem 安装随便"
$ rvm use 1.9.2
$ gem install "whatever"
这篇关于使用 RVM 在 Ubuntu 上安装 Rails Path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!