与 RVM 一起安装时找不到 Rails 命令行 [英] Rails command line not found when installed with RVM
问题描述
安装 RVM 后,我安装了 Ruby 1.8.7,然后是 Rails 3.当我执行 which rails
我得到 /Users/davidbenhamou/.rvm/gems/ruby-1.8.7-p302/bin/rails
.但是当我执行 rails -v
我得到 -bash:/usr/bin/rails: No such file or directory
After installing RVM, I have installed Ruby 1.8.7 then Rails 3.
When I do which rails
I get /Users/davidbenhamou/.rvm/gems/ruby-1.8.7-p302/bin/rails
.
But when I do rails -v
I get -bash: /usr/bin/rails: No such file or directory
为什么 Rails 不工作?注意:我遵循了 RVM 网站上的所有步骤,Ruby 命令行工作正常 (ruby -v
).
Why is Rails not working?
Note: I have followed all steps from RVM website and Ruby command line work fine (ruby -v
).
推荐答案
要查看您已安装的 rubies:
To see the rubies you have installed:
rvm list rubies
你会看到这样的:
ree-1.8.7-2011.03 [ i686 ]
* ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-p0 [ x86_64 ]
=> ruby-1.9.3-p125 [ x86_64 ]
ruby-1.9.3-p125-perf [ x86_64 ]
要使用特定的:
rvm use ruby-1.9.3-p125
然后如果你执行 ruby --version
,你会看到:
then if you do ruby --version
, you'll see:
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.7.0]
在每个这些红宝石中,您需要安装所有要使用的宝石.我这样做的方法实际上是使用 Bundler 为项目安装所有 gem.但是对于这里的简单情况,只需执行以下操作:
In each of these rubies you need to install all the gems you want to use. The way I do it is actually by using Bundler to install all the gems for a project. But for the simple case here, just do:
rvm all do gem install rails
这将在 所有 ruby 版本中安装 rails gem.要安装到特定的,请使用:
This will install the rails gem in all your ruby versions. To install to a particular one, use:
rvm ruby-1.9.3-p125 do gem install rails
这篇关于与 RVM 一起安装时找不到 Rails 命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!