Zsh & RVM woes (rvm-prompt doesn't resolve)

一个人想着一个人 提交于 2019-12-03 05:32:58

Make an alias to rvm-prompt. That's the most sure-fire answer. Arrange things in your .zshrc file in this order:

  1. alias rvm-prompt=$HOME/.rvm/bin/rvm-prompt
  2. source $ZSH/oh-my-zsh.sh
  3. [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

If oh-my-zsh (OMZ) loads before RVM, which rvm-prompt fails silently, so you won't see RVM in your prompt (if supported by your theme) even though it is in your path later, after RVM loads.

If RVM loads before OMZ, you may get a zsh: command not found: rvm-prompt.

Aliasing your rvm-prompt to its actual location seems to solve the problem, regardless of which order RVM and OMZ are loaded in. I'd still recommend RVM at the bottom.

Putting the RVM load into .zshenv as suggested above would load RVM twice in iTerm 2 (and no, it was not still in my .zshrc) and would result in the prompt displaying "system" even though rvm-prompt and rvm current showed a specific ruby version and gemset.

I had the same problem until I put [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" into a .zshenv file instead of the .zshrc file.

Not sure this will solve your problems, but it's worth a try anyways.

After a recent update to rvm, I had similar problems with oh-my-zsh. I uninstalled both rvm and oh-my-zsh then re-installed (install oh-my-zsh first, since it will copy a bunch or rvm paths into your ~/.zshrc if you install rvm first).

Things worked a little better, except rvm-prompt wouldn't work right with a new terminal window. I wound up sticking the following at the end of my ~/.zshrc and things work fine now:

rvm use default

I think some there is some kind of chicken-and-egg problem with the load order of rvm and oh-my-zsh with recent versions of rvm. Not sure which is to blame, but I hope it gets resolved by one or both of them!

The simplest way to get rid of it is to install RVM (Ruby Virtual Manager). You would then actually appreciate the theme.

curl -sSL https://get.rvm.io | bash

The problem resolves itself after that..

This problem is actually adressed in rvm's zsh-FAQ.

http://beginrescueend.com/integration/zsh/

adding __rvm_project_rvmrc to your .zshrc solves the issue.

I am adding this as an answer because I just found this while googling the issue and the above solution just sets the ruby version to rvm's default and does not work with gemsets.

lotosbin

Add the following to ~/.zshrc in

alias rvm-prompt=$HOME/.rvm/bin/rvm-prompt

Save

source ~/.zshrc

Reference: http://xufei.logdown.com/posts/2012/09/09/zsh-rake-rvm-prompt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!