bash RVM 设置 ruby 默认,当打开新终端时擦除 RVM 设置,回到系统 ruby
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12719027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
RVM set ruby default, when open new terminal erase the RVM setting, go back to system ruby
提问by MMA
I just got a new MacBook Pro and tried to setup the RVM in the system. I installed RVM and set the default to
我刚买了一台新的 MacBook Pro,并试图在系统中设置 RVM。我安装了 RVM 并将默认设置为
? rvm list default
? rvm list default
Default Ruby (for new shells)
Default Ruby (for new shells)
ruby-1.9.3-p194 [ x86_64 ]
ruby-1.9.3-p194 [ x86_64 ]
My RVM version is
我的 RVM 版本是
? rvm --version
? rvm --version
rvm 1.16.8 (master) by Wayne E. Seguin , Michal Papis [https://rvm.io/]
rvm 1.16.8 (master) by Wayne E. Seguin , Michal Papis [https://rvm.io/]
I have put [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.at the bottom of the .bashrc_profile.
我已经放在.bashrc_profile[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.的底部。
When I open the new Terminal window, I have done rvm defaultevery time to reset from system ruby to rvm installed ruby.
当我打开新的终端窗口时,我rvm default每次都从系统 ruby 重置为 rvm 安装的 ruby。
I have done 3 hours research and read more than 20 different blogs about this issue. And I still do not have a solution for this problem.
我已经进行了 3 个小时的研究,并阅读了 20 多个有关此问题的不同博客。我仍然没有解决这个问题的方法。
回答by Nick
If RVM isworking in the shell but just isn't using the preferred ruby as default, set it with the following for 1.9.3:
如果RVM正在工作的外壳,但只是没有使用首选红宝石作为默认情况下,以下为1.9.3设置:
rvm --default use 1.9.3
If RVM isn'tworking, it's likely a login shell problem that RVM isn't loading:
如果 RVM不工作,则可能是 RVM 未加载的登录 shell 问题:
Login shells (typically when a terminal window is opened in an X window manager) will use .bash_profilebut interactive, non-login shells reference .bashrc(likely where the rvm shell code are loaded).
登录 shell(通常在 X 窗口管理器中打开终端窗口时)将使用.bash_profile但交互式的非登录 shell 引用.bashrc(可能是加载 rvm shell 代码的位置)。
Option 1
选项1
Cheap fix, symlink them:
便宜的修复,符号链接它们:
ln -s ~/.bashrc ~/.bash_profile
ln -s ~/.bashrc ~/.bash_profile
Option 2
选项 2
Optionally, some terminals (e.g. gnome-terminal) offer settings to force login shells for each new terminal session too.
或者,某些终端(例如 gnome-terminal)也提供设置以强制每个新终端会话的登录 shell。
Option 3
选项 3
Create a .bash_loginfile with the following contents:
创建一个.bash_login包含以下内容的文件:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
(Bash will check for ~/.bash_profile, then ~/.bash_login, and finally ~/.profile.)
(Bash 将检查~/.bash_profile,然后~/.bash_login,最后~/.profile。)
See the bash man pagefor additional detailed information.
有关其他详细信息,请参阅bash 手册页。
回答by pje
I'm not familiar with a .bashrc_profilefile. I think you mean to have this line in your .profileor .bashrcfile.
我对.bashrc_profile文件不熟悉。我认为您的意思是在您的.profile或.bashrc文件中包含这一行。
回答by mpapis
There are to things to check:
有一些事情要检查:
go to terminal emulator, preferences, and enable login shell, sometimes it is required to use
/bin/bash --logininstead of just switching, put/bin/loginwould not work,one of
~/.bash*files might be resettingPATH, comment out anyPATH=...lines.
转到终端模拟器,首选项,并启用登录shell,有时需要使用
/bin/bash --login而不仅仅是切换,放置/bin/login不起作用,其中一个
~/.bash*文件可能正在重置PATH,注释掉任何PATH=...行。
After it is done make sure to open a new terminal (make sure to close it before).
完成后确保打开一个新终端(确保之前关闭它)。
回答by Lilspree
Use this $ source $(rvm 1.9.3 do rvm env --path)and specify the version you want to use everytime you open a terminal. After you put that in you don't need to open another one because it will default back. So if you want to use v. 2.2.1 $ source $(rvm 2.2.1 do rvm env --path)
使用它$ source $(rvm 1.9.3 do rvm env --path)并指定每次打开终端时要使用的版本。在你把它放进去之后,你不需要再打开一个,因为它会默认回来。所以如果你想使用 v. 2.2.1$ source $(rvm 2.2.1 do rvm env --path)

