Ruby on Rails RVM $PATH 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9018598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ruby on Rails RVM $PATH issue
提问by jimmyc3po
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".
使用https://rvm.beginrescueend.com/rvm/install/安装 ruby (ruby 1.9.2p290) & gems (没问题),然后通过gem install rails(Rails 3.2.0)安装 rails 。但是,当我尝试rails -v在我的 /user 目录以外的另一个目录中创建 rails 应用程序(或问题)时,我得到“当前未安装程序‘rails’。您可以通过键入以下内容进行安装:sudo apt-get install rails”我还注意到,如果我发出 ruby -v 我得到“当前未安装程序‘ruby’。您可以通过键入:sudo apt-get install ruby”来安装它。
Obviously, this is a $PATH issue but it's been so longsince I've had to do this that I've totally forgotten how to fix the issue. I'm thinking it's a simple fix but I'm feeling borderline retarded at the moment on how to solve this.
显然,这是一个 $PATH 问题,但自从我不得不这样做以来已经很长时间了,我完全忘记了如何解决这个问题。我认为这是一个简单的解决方法,但目前我对如何解决这个问题感到有点迟钝。
Again, as far as I can tell, as long as I create an app or issue command version commands...etc..in my /user directory all goes well.
同样,据我所知,只要我在我的 /user 目录中创建一个应用程序或发出命令版本命令......等等,一切顺利。
A few things that might help as well:
一些可能也有帮助的事情:
which railsgives me: /home/j3/.rvm/gems/ruby-1.9.2-p290/bin/rails
which rails给我:/home/j3/.rvm/gems/ruby-1.9.2-p290/bin/rails
which rubygives me: /home/j3/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
which ruby给我:/home/j3/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
thanks in advance, jim
提前致谢,吉姆
回答by prusswan
Seems like your rvm has not been added to PATH properly (or it was broken).
似乎您的 rvm 尚未正确添加到 PATH (或已损坏)。
Add this line to your profile settings (.bashrc or .bash_profile)
将此行添加到您的配置文件设置(.bashrc 或 .bash_profile)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
and source the file:
并获取文件:
source ~/.bashrc
or
或者
source ~/.bash_profile
Edit:You seem to have added the echo line to .bashrc by mistake, it should be executed in terminal.
编辑:您似乎错误地将 echo 行添加到 .bashrc 中,它应该在终端中执行。
回答by Simpleton
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 using rvm use --default {ruby version}to use that rvm version of ruby whenever you load a new terminal up.
当您尝试在您所在的任何目录中创建一个新的 rails 应用程序时,请务必输入rvm use {ruby version},您还可以通过rvm use --default {ruby version}在加载新终端时使用该 rvm 版本的 ruby 来设置默认值。

