I login in Centos 7 as root, installed Ruby via rvm and installed rails via gem.
I followed all the steps in this article: How to Install Ruby 2.2.2 on CentOS/RHEL with RVM
And when I login as user, ruby, gem and rails are all not found.
[ycyang@study projects]$ ruby -v
bash: ruby: command not found...
[ycyang@study projects]$ gem -v
bash: gem: command not found...
[ycyang@study projects]$ sudo gem -v
[sudo] password for ycyang:
sudo: gem: command not found
and it works as root:
[root@study projects]# ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
[root@study projects]# gem -v
2.4.8
How to set up my ruby and make it available to all users?
This is probably because your path doesn't include rvm when you are under your user.
You can edit your .bashrc or .bash_profile file and add the following:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Then you need to reload your profile with source ~/.bashrc
or source ~/.bash_profile
depending on which one you modified!
This is because rvm is not running. You can load it by:
source ~/.rvm/script/rvm
ruby -v
# ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
If the above solution works, you should add following in your .bashrc
file to load rvm everytime by default:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
If it still doesnot work, it may be because you installed rvm as root and now you are facing permission issues. In that case you may want to reinstall rvm is your current user (and not as root)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.