ruby 执行 rvm use 2.0.0 --default 时收到“警告!路径设置不正确”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18276701/
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
Getting "Warning! PATH is not properly set up" when doing rvm use 2.0.0 --default
提问by Michael Durrant
Above doesn't work first time, works 2nd time.
以上第一次不起作用,第二次起作用。
Try to set ruby version to 2.0.0 for any new shell windows.
对于任何新的 shell 窗口,尝试将 ruby 版本设置为 2.0.0。
Doing
正在做
$ rvm use 2.0.0 --default
gives
给
Warning! PATH is not properly set up, '/home/durrantm/.rvm/gems/ruby-1.9.3-p125/
bin' is not at first place,
usually this is caused by shell initialization files - check them for '
PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --au
to-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-1.9.3-p125'
.
Using /home/durrantm/.rvm/gems/ruby-2.0.0-p247
Then doing the same
然后做同样的
$ rvm use 2.0.0 --default
now gives no error, i.e.
现在没有错误,即
$ rvm use 2.0.0 --default
Using /home/durrantm/.rvm/gems/ruby-2.0.0-p247
durrantm.../durrantm$
but new windows are still giving me ruby 1.9.3, not 2.0.0
但是新窗口仍然给我 ruby 1.9.3,而不是 2.0.0
My .bashrcfile has in it:
我的.bashrc文件中有:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "/home/durrantm/.rvm/scripts/rvm" ]] && . "/home/durrantm/.rvm/scripts/rvm"
My .bash_profile has:
我的 .bash_profile 有:
source ~/.profile
case $- in *i*) . ~/.bashrc;; esac
Trying
试
rvm get stable
seems to work but at the end of a lot of green output shows:
似乎工作,但在很多绿色输出结束时显示:
Could not update RVM, get some help at #rvm IRC channel at freenode servers.
A new terminal windows with rvm list rubiesshows this:
一个新的终端窗口rvm list rubies显示了这个:
$ rvm list rubies
Warning! PATH is not properly set up, '/home/durrantm/.rvm/gems/ruby-1.9.3-p125/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-1.9.3-p125'.
rvm rubies
=> ruby-1.9.3-p125 [ x86_64 ]
ruby-1.9.3-p194 [ x86_64 ]
* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
回答by brandoncontreras
I was stuck after I uninstalled rvm with
卸载 rvm 后我被卡住了
rvm implode
then after reinstalling rvm it received the same error message. After looking through wayne seguin's git hub page. He lists tools on his page and recommended using
然后在重新安装 rvm 后,它收到相同的错误消息。在浏览了 wayne seguin 的 git hub 页面之后。他在他的页面上列出了工具并推荐使用
rvm reset
after an installation. This fixed my error message. No PATH edits needed.
安装后。这修复了我的错误消息。不需要 PATH 编辑。
回答by Michael Durrant
The answer was to put this:
答案是这样写的:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# Load RVM into a shell session *as a function*
**at the BOTTOM**(last line - important!) of my .bashrc file. I had it in my .bash_profile file (I am on Ubuntu) and that only partially worked leading to the confusing errors.
**在我的 .bashrc 文件的底部**(最后一行 - 很重要!)。我在我的 .bash_profile 文件(我在 Ubuntu 上)中有它,但它只是部分工作,导致了令人困惑的错误。
回答by Pedro José Piquero Plaza
Maybe is not the best way to resolve this, but I added this line at the botton of my .zshrc (it will work in .bashrc too!)
也许不是解决这个问题的最好方法,但我在我的 .zshrc 的底部添加了这一行(它也可以在 .bashrc 中工作!)
export PATH="$GEM_HOME/bin:$PATH"
回答by Sparkmasterflex
I tried Michael Durrant's solution and it didn't work for me. but I ran rvm get stable --auto-dotfilesand it began working as desired.
我尝试了 Michael Durrant 的解决方案,但对我不起作用。但我跑了rvm get stable --auto-dotfiles,它开始按预期工作。
Hope it helps
希望能帮助到你
回答by Sankalp
This isn't an answer to the question asked, but to the related question that most commenters/responders have asked -- Why do you need to put the rvm line at the bottom of the shell rc file?
这不是对所问问题的回答,而是对大多数评论者/回复者提出的相关问题的回答——为什么需要将 rvm 行放在 shell rc 文件的底部?
The answer is simple.
答案很简单。
- The rvm code which is loaded puts the rvm ruby binary directories at the "front" of
$PATH, and .bashrc(or equivalent for your default shell) is read and interpreted line-by-line from top to bottom.
- 加载的 rvm 代码将 rvm ruby 二进制目录放在
$PATH, 和 .bashrc(或等效于您的默认 shell)从上到下逐行读取和解释。
So imagine the following scenario :
所以想象一下下面的场景:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
$ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
/Users/sankalp/.rvm/gems/ruby-1.9.3-p547/bin:/Users/sankalp/.rvm/gems/ruby-1.9.3-p547@global/bin:/Users/sankalp/.rvm/rubies/ruby-1.9.3-p547/bin:/Users/sankalp/bin:/usr/texbin/:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
$ export PATH=<something>:$PATH
$ echo $PATH
<something>:/Users/sankalp/.rvm/gems/ruby-1.9.3-p547/bin:/Users/sankalp/.rvm/gems/ruby-1.9.3-p547@global/bin:/Users/sankalp/.rvm/rubies/ruby-1.9.3-p547/bin:/Users/sankalp/bin:/usr/texbin/:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
Clearly if something is present in the shell init file afterthe RVM line and makes any changes to $PATH, more specifically if it prepends directories to $PATH, then those changes will push the directories added by rvm down from their first position. RVM, when invoked, will find that its ruby binary directories are notat the very beginning of $PATHand BAM! you'll get the warning :) .
显然,如果在 RVM 行之后的 shell init 文件中存在某些内容并对 $PATH 进行了任何更改,更具体地说,如果它$PATH预先将目录添加到,那么这些更改会将 rvm 添加的目录从它们的第一个位置向下推。RVM 在调用时会发现它的 ruby 二进制目录不在$PATHBAM的最开始!你会收到警告:)。
I hope that makes things clear.
我希望这能让事情变得清楚。
回答by Ain Tohvri
Just adding my experience: if you're using .bash_profile, check if .bashrcis not interfering. Killing .bashrcin favour of single Bash configuration by .bash_profileworks out in this case.
只是添加我的经验:如果您正在使用.bash_profile,请检查是否.bashrc不干扰。在这种情况下,.bashrc通过杀死支持单个 Bash 配置.bash_profile。
回答by David Kim
I have a follow-up question to this (wish I could simply add comment - but I don't have enough credits). I had this very same issue - and when I followed the rvm script that was suggested using --auto-dotfiles, I got into trouble as it somehow the shell script deleted my .bashrc_profilefile.
我对此有一个后续问题(希望我可以简单地添加评论 - 但我没有足够的学分)。我遇到了同样的问题 - 当我遵循建议使用的 rvm 脚本时--auto-dotfiles,我遇到了麻烦,因为 shell 脚本以某种方式删除了我的.bashrc_profile文件。
Anyway, I eventually came around to the same answer listed above, putting this line at the bottom of .bashrcfile.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
无论如何,我最终找到了上面列出的相同答案,将这一行放在.bashrc文件的底部。
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Did you happen to find why that works the way it does, and not with the line in the middle of .bashrc file? Do you have some clarity around the way Unix is loading the environment variable that makes RVM work in one instance and not in another?
你有没有发现为什么它会这样工作,而不是 .bashrc 文件中间的那一行?您是否清楚 Unix 加载环境变量的方式,使 RVM 在一个实例中工作而不是在另一个实例中工作?
回答by Deepak Kabbur
I was facing same issue. I found that in bashrc file
我面临同样的问题。我在 bashrc 文件中发现
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
export PATH=$HOME/local/bin:$PATH
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
multiple entries for rvm. I commented one entry and its working fine.
rvm 的多个条目。我评论了一个条目并且它工作正常。
#export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
#export PATH=$HOME/local/bin:$PATH
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
回答by Caleb
I cleaned out everything that had a .rvm in it from my PATH= line in my .zshrc
我从 .zshrc 的 PATH= 行中清除了所有包含 .rvm 的内容
That fixed the issue for me, where the other answers here (sourcing the rvm script, or getting stable with auto dotfiles) didn't.
这为我解决了这个问题,这里的其他答案(采购 rvm 脚本,或使用自动点文件稳定)没有。
回答by castro4000
I have found this command to be very usefull.
It solve my case. So if anyone is having the same issue, give this a try:
rvm get stable --auto-dotfiles
我发现这个命令非常有用。它解决了我的情况。因此,如果有人遇到同样的问题,请尝试一下:
rvm get stable --auto-dotfiles

