Ruby command not recognized after installing it with rvm
Solution 1
You can install Ruby by typing:
sudo apt-get install ruby-full
See the Doc.
Solution 2
What went wrong?
During installation, rvm
puts two lines (first one is a comment though) in ~/.bash_profile
file to help bash
recognize ruby binaries. But the problem is Ubuntu's bash
ignores this file. As a result, it doesn't know that you already installed ruby and prompts you to install ruby!
The problem can be solved in two different way.
Solution 1: Using ~/.bashrc
file
Open your ~/.bashrc
file and put these two lines (or last one) there.
### Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Solution 2: Make the regular shell session as login shell
Or you can turn on your virtual terminal's preference to consider the shell as Login Shell. The settings can be found in -
-
Gnome Terminal: Menu > Edit > Profile Preference > Command Tab > Run command as a login shell
-
Mate Terminal: Menu > Edit > Profile Preference > Title & Command Tab > Run command as a login shell
-
Xfce4 Terminal: Menu > Edit > Preference > General Tab > Run command as login shell
Either one will do the job.
Another solution could be installing Ruby in System using Ubuntu's repository. But that defeats the purpose of using rvm
at first place.
Related videos on Youtube
Ramy Al Zuhouri
Updated on September 18, 2022Comments
-
Ramy Al Zuhouri over 1 year
I followed this tutorial to install ruby with rvm: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
The problem is that everytime that I log in, the ruby installation is not recognized, for example if I try executing a ruby script with the "ruby" command this is what I get:
To make it be recognized I have to run this command:
source ~/.rvm/scripts/rvm
But every time I login I have to do it again.
-
Bilal about 9 yearsThis article may help you Setup Ruby On Rails on Ubuntu
-
-
Tony Cronin over 7 yearsThis is the answer to the question asked. Why is it not the accepted answer?
-
Anwar over 7 years@TonyCronin This is added after 2 years, The OP might not active now. I appreciate your support though. Thanks !