rbenv and bundler: "bad interpreter: No such file or directory"

Badr Tazi picture Badr Tazi · Sep 29, 2015 · Viewed 11.9k times · Source

I messed up my configuration. I am running Ubuntu 14.04 and had some issues when I tried to move from a project to an other. I tried to uninstall and reinstall rbenv and then installed Ruby 2.1.7 following this guide: https://gorails.com/setup/ubuntu/14.04.

Now, when I run gem install bundler nothing happens and I can't install any gems. When I type bundler or bundler -v I see this:

/usr/local/bin/bundler: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory

I spent many hours trying to solve this but I really don't know what to do.

Answer

amit_saxena picture amit_saxena · Nov 17, 2015

Find the bundle executable (in a non project directory - default system ruby) and delete it:

which bundle

rm <path_obtained_above>

Now go to your project directory, or switch to your ruby version and install bundler:

gem install bundler

Then execute rbenv rehash

and now try executing bundle install and it should work. You will need to do this once for each ruby version installed.