2

I have no idea why but RVM can't seem to change the default Ruby. I'm using Oh My Zsh and tried everything I've found but nothing seems to work.

➜  Sites  rvm use 2.0.0 --default
Using /Users/anahkiasen/.rvm/gems/ruby-2.0.0-p247
➜  Sites  rvm list
rvm rubies

=* ruby-2.0.0-p247 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

➜  Sites  rvm reload && rvm list
RVM reloaded!

rvm rubies

 * ruby-2.0.0-p247 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

Now the Ruby is set as default but RVM doesn't load it as "current", which means it does not load the gemsets that are affiliated to it.

➜  Sites  rvm use 2.0.0
Using /Users/anahkiasen/.rvm/gems/ruby-2.0.0-p247
➜  Sites  gem list

*** LOCAL GEMS ***

backports (3.3.3)
bson (1.9.1)
bson_ext (1.9.1)
bundler (1.3.5)
bundler-unload (1.0.1)
eventmachine (1.0.3)
genghisapp (2.3.7)
json (1.8.0)
mongo (1.9.0)
mustache (0.99.4)
rack (1.5.2)
rack-protection (1.5.0)
rack-test (0.6.2)
rake (10.1.0)
rubygems-bundler (1.2.2)
rvm (1.11.3.8)
sass (3.2.10)
sass-globbing (1.1.0)
sinatra (1.4.3)
sinatra-contrib (1.4.0)
sinatra-mustache (0.1.0)
tilt (1.4.1)
vegas (0.1.11)
➜  Sites  rvm reload && gem list
RVM reloaded!

*** LOCAL GEMS *** 

Nothing.

I have no .bashrc nor .bash_profile. There is no RVM reference in my .zprofile and here is my .zshrc :

# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh

# Set name of the theme to load.
ZSH_THEME="robbyrussell"
DEFAULT_USER="anahkiasen"

# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
plugins=(git bower brew composer gem laravel sublime)

## RVM and Rubygems
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

source $ZSH/oh-my-zsh.sh

I've tried swapping the above two lines, tried moving the RVM loading into .zprofile, nothing. Everytime I open a new instance of the terminal, the default is gone. It loads the correct ruby, meaning if I do ruby -v I get the version I want, but for RVM it's not loaded and thus I have none of the gemsets.

I've also tried rvm --default use 2.0.0, rvm use 2.0.0@develop --default but same result.

I've reinstalled RVM, I've set recursively the permissions of the .rvm folder to the current user, nothing.

I'm kind of desperate at that point.

Maxime Fabre
  • 2,252
  • 3
  • 20
  • 24

2 Answers2

6

As you are using OH-MY-ZSH you might be hitting issue similar to this: https://github.com/robbyrussell/oh-my-zsh/pull/1359

RVM has a "fix" function, run:

rvm get head --auto-dotfiles

It will reorganize your dot files - it is important to read the output and follow instructions.

Make sure to use login shell for best effect.

mpapis
  • 52,729
  • 14
  • 121
  • 158
  • Unfortunately that didn't change anything, it replaced the lines in the correct dotfiles but the bug persists. – Maxime Fabre Aug 04 '13 at 01:11
  • did you get info about forced `PATH` and follow instructions to remove it? – mpapis Oct 28 '14 at 08:25
  • My ruby version changes back to system installed old ruby when I run `source ~/.zshrc`. I fix it by commenting out the PATH setting line in .zshrc as the pull request suggested. – lingceng Jul 02 '15 at 06:54
1

Ah ha !! I just faced the same problem and resolved it eventually.

Let me reiterate my issue: Everytime i start my terminal, i had to first do a bundle install each time. Then i figured, Its not correct. So i tried sourcing my zshrc.

So everytime i had to do source ~/.zshrc or simply zsh also did the same and my gemset would get identified. Ofcourse assuming RVM and all other dependencies are installed correctly

Finally i figured i needed to do the following:

  • $ vim ~/.zlogin

  • The contents of the .zlogin should be

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
    zsh   #to initiate zsh (you could also replace this with 'source ~/.zshrc')
    

This resolved my problem. Now everytime i start my terminal, my defaults are all set.

Let me know if this works for you.

Vishnu Narang
  • 605
  • 8
  • 15