Ruby on Rails RVM $PATH 问题
我使用 https://rvm.beginrescueend.com/rvm/install/ 安装 ruby (红宝石 1.9.2p290) gems(没问题),然后通过gem安装rails安装rails(Rails 3.2.0),但是当我尝试创建rails应用程序(或发出rails -v)时在 /user 目录以外的另一个目录中,我得到:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
我还注意到,如果我发出 ruby -v ,我得到:
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt-get install ruby
显然,这是一个 $PATH 问题,但自从我发布以来已经很久了我必须这样做我完全忘记了如何解决这个问题。
据我所知,只要我在 /user 目录中创建应用程序或发出命令版本命令,一切都会顺利。
一些可能也有帮助的事情:
which Rails
给了我:/home/j3/.rvm/gems/ruby-1.9.2-p290/bin/rails
which ruby
给我:/home/j3/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
I used https://rvm.beginrescueend.com/rvm/install/ to install ruby (ruby 1.9.2p290) & gems (no problems), then installed rails via gem install rails
(Rails 3.2.0), but when I try and create a rails app (or issue rails -v
) in another directory other than my /user directory I get:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I also noticed that if I issue ruby -v
, I get:
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt-get install ruby
Obviously, this is a $PATH issue, but it's been so long since I've had to do this that I've totally forgotten how to fix the issue.
As far as I can tell, as long as I create an app or issue command version commands in my /user directory, all goes well.
A few things that might help as well:
which rails
gives me: /home/j3/.rvm/gems/ruby-1.9.2-p290/bin/rails
which ruby
gives me: /home/j3/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎您的 rvm 尚未正确添加到 PATH(或者已损坏)。
将此行添加到您的配置文件设置(.bashrc 或 .bash_profile)
并获取文件:
或
编辑: 您似乎错误地将 echo 行添加到 .bashrc,它应该在终端中执行。
Seems like your rvm has not been added to PATH properly (or it was broken).
Add this line to your profile settings (.bashrc or .bash_profile)
and source the file:
or
Edit: You seem to have added the echo line to .bashrc by mistake, it should be executed in terminal.
当您尝试在所在目录中创建新的 Rails 应用程序时,请务必输入
rvm use {ruby version}
并且您还可以使用rvm use --default 设置默认值{ruby version}
每当加载新终端时都使用该 rvm 版本的 ruby。When you try to create a new rails app in whichever directory you are in, be sure to type
rvm use {ruby version}
and you can also set a default by usingrvm use --default {ruby version}
to use that rvm version of ruby whenever you load a new terminal up.