Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rbenv continually generating vagrant shim

I am using the latest vagrant with rbenv and various rubies.

I am using the latest vagrant, which no longer uses a gem. When I execute a vagrant command I see the following error:

rbenv: vagrant: command not found

I have removed the old vagrant gem from all ruby environments BUT everytime I "cd" the vagrant shim is regenerated, meaning vagrant stops working until I rm the shim manually:

rm /home/{user}/.rbenv/shims/vagrant   

Is there a way to force rbenv to stop this behaviour?

rbenv plugins in use":

  • ruby-build
  • rbenv-gemset
like image 906
Toby Hede Avatar asked May 11 '13 10:05

Toby Hede


People also ask

What is rbenv shims?

rbenv-shim gets created during the rehash process to indicate a rehash is in progress. If a previous rehashing was interrupted in the middle or couldn't finish for some reason, the file will still be there. It then needs to be deleted manually, so that you can rehash again.

What does rbenv rehash?

Through the rehash sub-command, rbenv maintains shims in that directory to match every Ruby command across every installed version of Ruby on your server. Whenever you install a new version of Ruby or a gem that provides commands, such as Rails, you should use rehash .


2 Answers

Until this issue is resolved in rbenv, you could do this:

alias vagrant /full/path/to/vagrant

Then everytime you run vagrant, the actual vagrant binary will be executed, rather than the shim.

like image 105
Subhas Avatar answered Sep 20 '22 23:09

Subhas


Other people have apparently had the same problem; see https://github.com/sstephenson/rbenv/issues/388.

If you are using the bundler plugin for rbenv, then vendoring a project which uses the vagrant gem will evidently cause the shim to be built; try removing the bundler plugin, remove the vagrant shim, and run rbenv rehash to see the problem is fixed.

If you aren't using the bundler plugin, can you give us a list of all the rbenv plugins you are using?

like image 45
Wally Altman Avatar answered Sep 22 '22 23:09

Wally Altman