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条回答
冷血范
2楼-- · 2019-01-10 21:12

I had the same problem and since I use Oh-My-Zsh it was a little bit more difficult to track if I have duplicate calls to RVM.

I fixed it by moving the call to RVM from the separate rvm.zsh file located in my \custom folder inside \oh-my-zsh to the very end of my main .zshrc file.

It looks like RVM is really sensitive to being called not at the end of your zsh initialization sequence.

查看更多
小情绪 Triste *
3楼-- · 2019-01-10 21:13

My issue was resolved by changing:

PATH=/usr/local/bin to PATH=$PATH:/usr/local/bin in my .zshrc

source @github RVM issue queue

Obviously, you need to make sure RVM is properly installed first, and run the type rvm | head -1 check that @choise suggested. rvm use --default 1.9.3-p362 now works properly.

查看更多
Rolldiameter
4楼-- · 2019-01-10 21:14

I had the same issue on Mac OS X 10.7.

And later I found that my account was not added to "rvm" group.

After I add myself to rvm group, I can set --default of rvm.

查看更多
Explosion°爆炸
5楼-- · 2019-01-10 21:14

You need to put the path to rvm in front of your PATH

$ export PATH=/path/to/rvm-dir:$PATH
查看更多
萌系小妹纸
6楼-- · 2019-01-10 21:14

what does type rvm | head -1 print out?

in my bash_profile (on the latest osx) i had to put

# Ruby Version Manager
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm"

i also created a gemset and setted this as default:

rvm reload
rvm install 1.9.2
rvm --create use 1.9.2@default
rvm --default use 1.9.2@default
查看更多
别忘想泡老子
7楼-- · 2019-01-10 21:16

I had the same problem once. Turned out the rvm-script got loaded twice, which broke things a bit.

Check all the files that get loaded when you open a shell, e.g. /etc/profile, ~/.bashrc, ~/.bash_profile and so on, and make sure they don't load RVM twice.

Maybe put echo "Going to load RVM" before [[ -s "/Users/user/.rvm/scripts/rvm" ]] && source "/Users/user/.rvm/scripts/rvm" in your ~/.bash_profile to see if it happens or not

查看更多
登录 后发表回答