Search code examples
rubyrubygemsbundlerbenv

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


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.


Solution

  • The fact that gem is being executed by your /usr/local/bin means that rbenv isn't in your $PATH correctly.

    Step 1:

    Please delete any references you have of rbenv in the following areas:

    • ~/.profile
    • ~/.bashrc
    • ~/.bash_profile
    • ~/.gemrc

    Step 2:

    Reinstall rbenv using these instructions. It won't override, it will simply update changes to your ~/.bash_profile. Once reinstalled close your terminal and reopen. Everything should work correctly at that time.

    Step 3:

    Verify that everything was installed correctly by executing cat ~/.bash_profile. You should see the following. If you do, you're good to go.

    export PATH="$HOME/.rbenv/bin:$PATH"
    eval "$(rbenv init -)"
    

    Many cudos to @theTinMan for recently helping me sort through my rbenv installation.