问题
sergio@sergio-VirtualBox:~/code$ rails -v
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
sergio@sergio-VirtualBox:~/code$ source ~/.profile
sergio@sergio-VirtualBox:~/code$ rails -v
Rails 3.2.1
Any ideas why the command doesn't work until I run "source ~/.profile"? I would like to not have to do this every time I run my machine or open a new terminal window.
回答1:
RVM provides quite good description https://rvm.io/support/faq/#shell_login
you should use .bash_profile - unless you have good reasons against it - but I do not know many.
Rvm puts a sourcing line in one of your RC files, in your case it was .profile, you should remove that line, create .bash_profile, and update rvm:
sed -i '/source.*rvm/ d' ~/.profile
touch ~/.bash_profile
rvm get head --auto-dotfiles
回答2:
Your shell isn't loading your ~/.profile. Probably it is loading ~/.bashrc or ~/.bash_profile or one of a few other possible things. Consult the documentation for your shell, or run it under strace
to see what files it loads when it starts.
来源:https://stackoverflow.com/questions/9106635/rvm-isnt-recognized-until-i-run-source-profile-in-terminal