RVM set ruby default, when open new terminal erase

2019-04-25 09:45发布

I just got a new MacBook Pro and tried to setup the RVM in the system. I installed RVM and set the default to

➜ rvm list default

Default Ruby (for new shells)

ruby-1.9.3-p194 [ x86_64 ]

My RVM version is

➜ rvm --version

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.

When I open the new Terminal window, I have done rvm default every time to reset from system ruby to rvm installed 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.

4条回答
ゆ 、 Hurt°
2楼-- · 2019-04-25 10:07

I'm not familiar with a .bashrc_profile file. I think you mean to have this line in your .profile or .bashrc file.

查看更多
我只想做你的唯一
3楼-- · 2019-04-25 10:10

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)

查看更多
一纸荒年 Trace。
4楼-- · 2019-04-25 10:15

If RVM is working in the shell but just isn't using the preferred ruby as default, set it with the following for 1.9.3:

rvm --default use 1.9.3

If RVM isn't working, it's likely a login shell problem that RVM isn't loading:

Login shells (typically when a terminal window is opened in an X window manager) will use .bash_profile but interactive, non-login shells reference .bashrc (likely where the rvm shell code are loaded).

Option 1

Cheap fix, symlink them:

ln -s ~/.bashrc ~/.bash_profile

Option 2

Optionally, some terminals (e.g. gnome-terminal) offer settings to force login shells for each new terminal session too.

Option 3

Create a .bash_login file with the following contents:

[[ -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.)

See the bash man page for additional detailed information.

查看更多
你好瞎i
5楼-- · 2019-04-25 10:20

There are to things to check:

  1. go to terminal emulator, preferences, and enable login shell, sometimes it is required to use /bin/bash --login instead of just switching, put /bin/login would not work,

  2. one of ~/.bash* files might be resetting PATH, comment out any PATH=... lines.

After it is done make sure to open a new terminal (make sure to close it before).

查看更多
登录 后发表回答