简体   繁体   English

使用RVM安装时找不到Rails命令行

[英]Rails command line not found when installed with RVM

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 . 安装RVM之后,我安装了Ruby 1.8.7然后安装了Rails 3.当我执行which rails我得到/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 -v我得到-bash: /usr/bin/rails: No such file or directory

Why is Rails not working? 为什么Rails不工作? Note: I have followed all steps from RVM website and Ruby command line work fine ( ruby -v ). 注意:我已经完成了从RVM网站和Ruby命令行工作的所有步骤( ruby -v )。

To see the rubies you have installed: 要查看已安装的红宝石:

rvm list rubies

And you'll see something like this: 你会看到这样的事情:

   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 ]

To use a specific one: 要使用特定的一个:

rvm use ruby-1.9.3-p125

then if you do ruby --version , you'll see: 那么如果你做ruby --version ,你会看到:

ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.7.0]

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. 我这样做的方法实际上就是使用Bundler来安装项目的所有宝石。 But for the simple case here, just do: 但对于这里的简单案例,只需:

rvm all do gem install rails

This will install the rails gem in all your ruby versions. 这将在所有 ruby版本中安装rails gem。 To install to a particular one, use: 要安装到特定的一个,请使用:

rvm ruby-1.9.3-p125  do gem install rails

after you installed RVM and after you set the default Ruby version in RVM, you need to re-install all ruby gems, eg 安装RVM后,在RVM中设置默认的Ruby版本后,需要重新安装所有ruby gems,例如

gem install rails 宝石安装导轨

you need to install those gems as the user, not as root. 你需要以用户身份安装这些宝石,而不是root用户。

Because from now on RVM will keep track of all installed gems by the ruby version which was used to install them! 因为从现在开始,RVM将通过用于安装它们的ruby版本跟踪所有已安装的gem!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM