在终端中运行"source~/.profile"之前,无法识别RVM

Onl*_*ere 1 linux profile ubuntu rvm

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
Run Code Online (Sandbox Code Playgroud)

在我运行"source~/.profile"之前,为什么命令不起作用的任何想法?我不想每次运行机器或打开新的终端窗口时都这样做.

mpa*_*pis 7

RVM提供了非常好的描述https://rvm.io/support/faq/#shell_login

你应该使用.bash_profile - 除非你有充分的理由反对它 - 但我不知道很多.

Rvm在你的一个RC文件中放置一个源代码行,在你的情况下它是.profile,你应该删除该行,创建.bash_profile,并更新rvm:

sed -i '/source.*rvm/ d' ~/.profile
touch ~/.bash_profile
rvm get head --auto-dotfiles
Run Code Online (Sandbox Code Playgroud)