rvm /usr/bin/env: ruby no such file error
Solution 1
The PATH is what the env
program uses to search for your executables. You can change this per-user (in the $HOME/.bashrc). In order to do that, run nano $HOME/.bashrc
and go to the last line, add a new line
export PATH=$PATH:/usr/local/rvm/rubies/ruby-2.1.1/bin
To change it at a system level you sudo nano /etc/login.defs
and change this line
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
to
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/rubies/ruby-2.1.1/bin
Solution 2
I recently faced this issue and took a different approach, so thought of sharing it. This happens when the ruby file is not present in the directory mentioned. So create a symbolic link to the ruby file in the directory and your error should be fixed.
cd /usr/bin/env
ln -s /usr/local/rvm/rubies/ruby-2.1.1/bin/ruby
Solution 3
I realize this is a somewhat old question, but I spent a day+ trying to nail this problem down, and I found what I think is a solid best practices type of solution -- use the rvm
wrappers.
/usr/bin/env ruby
gives you the capability to use the Ruby version of your choice so you don't have to edit the executable shell scripts (in /bin
) with a hard coded directory path to make them work (I've seen this as a suggested fix elsewhere).
As noted in the answers above, the key is the $PATH
setting in /etc/environment
, but I came up with a different solution.
RVM gives us a symbolic link directory of all the installed ruby versions and aliases at /usr/local/rvm/wrappers/
.
If you set your $PATH
var to use the wrapper directory associated with the Ruby version you want to use e.g.
PATH="/usr/local/rvm/wrappers/ruby-1.9.3-p547:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
You will have set the RVM environment such that /usr/bin/env ruby_command
will work.
At least this resolved this problem for me. I hope this helps someone out there save some time.
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I've installed rvm + ruby systemwide.
which ruby /usr/local/rvm/rubies/ruby-2.1.1/bin/ruby
and:
/usr/bin/env: ruby: No such file or directory
Everything else works fine, putting direct path of ruby in my executables work fine.
-
Elliott Frisch about 10 yearsHave you added "/usr/local/rvm/rubies/ruby-2.1.1/bin" to the "PATH" in "/etc/login.defs"?
-
-
Gunnar Hjalmarsson about 10 years@SandroDzneladze: In Ubuntu the PATH variable is set in
/etc/environment
. That's where I would change it rather than in/etc/login.defs
. -
WIN10DBubuntu about 10 years@GunnarHjalmarsson looks like a better place yes. But it doesn't fix the problem.
-
AMIC MING over 8 yearsI tried the solution, somehow it is not working for ruby-2.2.2 and Ubuntu 14.04.2 LTS
-
AMIC MING over 8 yearsI tried the solution, somehow it is not working for ruby-2.2.2 and Ubuntu 14.04.2 LTS
-
Va As over 8 yearsWhat's the error? There are some install issues on Ubuntu with Ruby 2.2.+: ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you I'm still using v1.9.3 -- not looking forward to upgrading.
-
Matt Bruzek over 8 yearsHello Nihanth and than you for the answer! /usr/bin/env is not a directory on Ubuntu machines. Also your link command is missing a parameter.