7

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
Toby Hede
  • 36,755
  • 28
  • 133
  • 162

3 Answers3

5

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.

Subhas
  • 14,290
  • 1
  • 29
  • 37
3

Try:

ls ~/.rbenv/versions/*/bin | grep 'vagrant'

and if have gemset plugin

ls ~/.rbenv/*/gemsets/*/bin/ | grep 'vagrant'

If commands return results, delete the files. After this run rbenv rehash.

byterussian
  • 3,539
  • 6
  • 28
  • 36
3

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?

Wally Altman
  • 3,535
  • 3
  • 25
  • 33
  • Had a similar issue with `docker`. The issue thread referenced above (#388) solved it for me. It was the `~/.rbenv/bundles` file that referenced a project on my system which contained a `bin/docker` binary... After `rm ~/.rbenv/bundles && rbenv rehash` the stale `docker` shim finally did not reappear. – bovender Jul 16 '18 at 14:23