tpope / vim-rvm

rvm.vim: Switch Ruby versions from inside Vim
http://www.vim.org/scripts/script.php?script_id=4269
117 stars 5 forks source link

Problems with path after changing ruby #5

Open avivrosenberg opened 10 years ago

avivrosenberg commented 10 years ago

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

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

tpope commented 10 years ago

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.)

MinasMazar commented 8 years ago

I have experienced exactly the same problem.

MinasMazar commented 8 years ago

@avivrosenberg could you test and feedback me?

avivrosenberg commented 8 years ago

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!