4

I'm facing a problem I have never had before. The other day when I was going into a ruby project of mine that is in Sinatra and went to do a bundle install I got this error:

/Users/me/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:762:in `report_activate_error': Could not find RubyGem bundler (>= 0) (Gem::LoadError)

Odd I thought and went ahead typing

gem list

and there I saw:

bundler (1.0.21, 1.0.2)

So there bundler is. Then after trying uninstalling bundler and reinstalling, switching ruby -v with rvm I tried running any other gem I have, like rails. So I ran rails s and bam, I got the same error as with bundler:

 /Users/me/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:762:in`report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)

What is going on? I then tried the same thing with all my gems and all gives the same error. Has this anything to do with rvm? I can't seem to remeber doing anything out of the ordinary these last couple of days that can have caused this. The only thing I have done is switching to ZShell with Oh My ZSH, but that can't have anything to do with this. What can be the problem? Should uninstall rvm altogether and reinstall it and then add the ruby -v I have again? My environment is Mac OS X Lion. Thanks in advance.

EDIT:

I now got it to roll. My switch to oh my zsh was indeed what was causing the problem. Amongst the places where I found the answer was here: https://stackoverflow.com/a/4755696/434299

Basically what you need to do is in your

~/.zshrc

Add this line:

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

Which loads rvm into a shell session. Problem solved! Thanks to Felix Rabe for pointing me in the right direction.

Community
  • 1
  • 1
Tim
  • 531
  • 2
  • 7
  • 25
  • I have several thoughts on this, but no answer. First: Have you tried SlimGems? What do you get when you `which` your commands? Like `which gem` or `which bundler`? Can you do `require 'bundler/setup'` in IRB and get true? – Felix Rabe Jan 16 '12 at 21:44
  • Im getting a `undefined local variable or method bundler for main:Object` in irb. On `which bundler` I get bundler not found. On `gem` I get /Users/me/.rvm/rubies/ruby-1.9.2-p0/bin/gem. What do you make of this? – Tim Jan 16 '12 at 21:55
  • I have another reply ready, but just thought of your switch to ZSH. Maybe the problem *is* there. Do you have RVM correctly set up to work with ZSH? – Felix Rabe Jan 16 '12 at 22:17
  • Sorry, meant `which bundle` of course. Other things I would check are `bundle -v` and `gem -v`. Also, see what you get for all these in Bash. – Felix Rabe Jan 16 '12 at 22:17
  • Just googled for `zsh rvm` and found http://beginrescueend.com/integration/zsh/, where it says at the bottom: "If you want to use oh my zsh be sure not to use the bundler package. If rvm should take care of everything this would do for you anyways." – Felix Rabe Jan 16 '12 at 22:21
  • Felix: Thanks for the answer. I did not know that my switch to oh my zsh could cause this. I'm going to look into that when I get back home. If thats the solution I will mark your answer as correct. Thanks. – Tim Jan 17 '12 at 07:26
  • Adding that line to my `.zshrc` file worked a treat! Saved me hours of grief. +1 – Jules Copeland May 22 '12 at 09:04

2 Answers2

3

Your use of "Oh my ZSH" together with RVM could be the cause. I googled for zsh rvm and found http://beginrescueend.com/integration/zsh, where it says at the bottom:

If you want to use oh my zsh be sure not to use the bundler package. If rvm should take care of everything this would do for you anyways.

(Copied from my comment above to get an "accept-able" answer.)

Felix Rabe
  • 4,206
  • 4
  • 25
  • 34
  • great:) will check first thing when I get back home(as the error is on my private machine at home). – Tim Jan 17 '12 at 12:24
  • Felix/Tim, would you care to explain this further? I've read the rvm doc page that was mentioned and it made no sense to me... Additionally, i solved this issue via another route which i will leave as an answer. – Mario Zigliotto Dec 27 '12 at 16:18
  • I'm sorry, I don't use ZSH myself, so I neither have the skill to help you out nor the interest to investigate further. It is very likely that you found a better solution than me. – Felix Rabe Dec 27 '12 at 23:18
0

I fixed this differently.

My ~/.zshrc now has this line for the plugins and it solved the issues i was having:

plugins=(git bundler brew git osx ruby zsh-syntax-highlighting)

This is similar to the config that Ryan Bates uses here: http://railscasts.com/episodes/308-oh-my-zsh

Mario Zigliotto
  • 8,315
  • 7
  • 52
  • 71