Linux – /usr/bin/env is pointing to wrong ruby version. “No such file or directory”

environment-variableslinuxpathruby

If I type "rake spec" I get.
/usr/bin/env: ruby1.9.1: No such file or directory
This problem started happening when I uninstalled ruby 1.9.1 and used rvm to install the latest ruby version but now when I type rails -v or rake spec, they're still pointing to the old nonexisting ruby.

This is what my bashrc looks like

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

export PATH="/usr/local/bin:$PATH"
export PATH="$PATH:$HOME/.linuxbrew/bin"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
export PATH=$PATH:/usr/local/rvm/rubies/ruby-2.1.1/bin

What do I do?

Another error when I try bundle install I get

-bash: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory

Best Answer

It is possible that PATH still contains the old ruby location (/usr/bin/env).

Try appending your new ruby bin before $PATH.

Like follows:

export PATH=/new_bin/:$PATH

If another ruby bin path is before the new one, it will be of higher priority in PATH.

Related Question