Why doesn't “RVM --default” work for me on Mac

2019-01-10 20:29发布

After using Ruby and Rails for quite some time now, i wanted to try RVM. Everything works fine, except for one thing:

In a freshly opened Terminal ruby points to the system's ruby, despite the fact, that I used the rvm --default command.

user@terra ~ $ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]
user@terra ~ $ which ruby
/opt/local/bin/ruby
user@terra ~ $ rvm list
   ruby-1.8.7-p334 [ ]
=> ruby-1.9.2-p180 [ ]

Everything is fine after I call rvm reload

user@terra ~ $ rvm reload
user@terra ~ $ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.1]
tmangner@terra ~ $ which ruby
/Users/user/.rvm/rubies/ruby-1.9.2-p180/bin/ruby

I've set up my .bash_profile as described in the documentation:

...
[[ -s "/Users/user/.rvm/scripts/rvm" ]] && source "/Users/user/.rvm/scripts/rvm" 

Thanks for your help. It is highly appreciated.

I'm using Mac OS X Snow Leopard (10.6.6)

Update:

That --default does not seem to work for me ...

user@terra ~ $ rvm use 1.9.2 --default
Using /Users/user/.rvm/gems/ruby-1.9.2-p180
user@terra ~ $ rvm default
user@terra ~ $

标签: ruby macos rvm
18条回答
可以哭但决不认输i
2楼-- · 2019-01-10 21:03

A possible fix for ZSH users:

Somehow I had:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

in both .zprofile and .zshrc.

Removing the line from .zprofile resolved the issue. (Though you should be able to remove from either, as long as it appears just once)

查看更多
来,给爷笑一个
3楼-- · 2019-01-10 21:03

I had the same problem. Moving the line: [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

after the line from MacPorts: export PATH=/opt/local/bin:/opt/local/sbin:$PATH

solved the problem for me.

查看更多
一纸荒年 Trace。
4楼-- · 2019-01-10 21:03

same pb here. line was there twice and it broke it.... for whatever reason... removing the extraneous line solved it

查看更多
贪生不怕死
5楼-- · 2019-01-10 21:06

Moving this:

[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm"

in the bottom of ~/.bash_profile solved the problem for me.

查看更多
祖国的老花朵
6楼-- · 2019-01-10 21:06

Instead of:

rvm use 1.9.2 --default 

I used the full version:

rvm use ruby-1.9.2-p290 --default 

That worked for me in zsh.

查看更多
淡お忘
7楼-- · 2019-01-10 21:11

sanity check - make sure that the project you are working on has the same ruby version that you try to set as default in the .ruby-version file.

it happened to me, and i couldn't figure out why rvm doesn't use my default

查看更多
登录 后发表回答