vim-rvm icon indicating copy to clipboard operation
vim-rvm copied to clipboard

Problems with path after changing ruby

Open avivrosenberg opened this issue 11 years ago • 4 comments

Using rvm 1.22.19 (stable), Vim 7.4 (MacVim built by homebrew), latest vim-rvm. My .bash_profile, .profile and .bashrc are configured similar to what they are after rvm get stable --auto-dotfiles. In the terminal, RVM works great.

Heres a screenshot with the dotfiles: screenshot 2013-10-09 19 29 11

The issue

After I change the ruby version once, the PATH gets mangled and RVM refuses to behave. Attempting to change the ruby version again produces an error.

Steps to reproduce

  1. In a fresh instance of MacVim:
:Rvm current

produces: ruby-2.0.0-p247, which is the default. So far so good.

  1. Changing the ruby version, and checking it:
:Rvm 1.9.3
:Rvm current

produces this warning:

Warning! PATH is not properly set up, '/Users/aviv/.rvm/gems/ruby-1.9.3-p448/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-p448'.

Running `!ruby -v` from vim **does** show the correct version. However, running `:echo $PATH` shows that the path is mangled (not the same as after `rvm use 1.9.3` when run from terminal): `/Users/aviv/.rvm/rubies/ruby-1.9.3-p448/bin:/Users/aviv/.rvm/gems/ruby-1.9.3-p448/bin:/Users/aviv/.rvm/gems/ruby-1.9.3-p448@global/bin:/Users/aviv/.rvm/bin:<rest_of_path...>`. You can see that as the warning says, the path order is wrong.
  1. Changing the ruby version again:
:Rvm 2.0.0

produces a nasty error:

Ruby version not installed: :Rvm install Warning! PATH is not properly set up, '/Users/aviv/.rvm/gems/ruby-1.9.3-p448/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-p448'.^@ruby-2.0.0-p247

Now, `ruby -v` shows the wrong version (1.9.3 instead of 2.0.0). Any further attempt to use vim-rvm from this point forward seems to fail with the same error.

Things I've tried

  • Removed all RVM-related stuff from my dotfiles. In the terminal, rvm get stable --auto-dotfiles to use the default dotfile configuration without any other modifications on my part. Same error.
  • In vimrc, set shell=bash\ --login. This causes vim-rvm to not work at all: it can't even change the ruby version once.

Thanks for your help and for creating so many awesome vim plugins.

avivrosenberg avatar Oct 10 '13 05:10 avivrosenberg

I wonder if this is due to a recent change in RVM. Anyone else experiencing success or failures? (I don't have an RVM install handy to check at the moment.)

tpope avatar Oct 10 '13 06:10 tpope

I have experienced exactly the same problem.

MinasMazar avatar Nov 12 '15 22:11 MinasMazar

@avivrosenberg could you test and feedback me?

MinasMazar avatar Nov 13 '15 02:11 MinasMazar

Hi @MinasMazar, sorry for the delay, I don't use this plugin anymore so I needed to find the time to remember what this was all about... :) Initially tried to recreate this to test your fix but for some reason I didn't get the error, and in fact nothing else worked either (ruby versions didn't change no mater what I did). So I left it alone for a while until I had the free time to investigate...

Turns out the plugin doesn't work at all under zsh. I moved to zsh a while back and forgot about it, and that's why I couldn't recreate it. Probably this should be a separate issue...

Anyway, I used set shell=bash in vim and then I was able to recreate this error with a newer RVM (1.26.11).

I tested your pull request and it does indeed fix the problem for me as well. :+1:

Thanks!

avivrosenberg avatar Nov 28 '15 10:11 avivrosenberg