tags:

views:

645

answers:

4

I found some similar problems here on SO, but none seem to match my case (sorry if I overlooked). Here's my problem: I installed oauth-plugin gem to ruby gems dir, but trying to use it in rails app tells me that it's not being found. Here's the output of relevant commands:

Instalation

% s gem install oauth-plugin
Successfully installed oauth-plugin-0.3.14
1 gem installed
Installing ri documentation for oauth-plugin-0.3.14...
Installing RDoc documentation for oauth-plugin-0.3.14...

gem which oauth-plugin output:

% gem which oauth-plugin
/usr/lib/ruby/gems/1.8/gems/oauth-plugin-0.3.14/lib/oauth-plugin.rb

gem env output:

% gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.6
  - RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-10
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /Users/eimantas/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => true
     - :bulk_threshold => 1000
     - :gem => ["--no-ri", "--no-rdoc"]
     - :sources => ["http://gems.ruby.lt/", "http://rubygems.org/"]
  - REMOTE SOURCES:
     - http://gems.ruby.lt/
     - http://rubygems.org/

Doing ls -l /usr/lib/ruby shows this:

% ls -l /usr/lib/ruby     
lrwxr-xr-x  1 root  wheel  76 Aug 14  2009 /usr/lib/ruby -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby

And the gem in question is in intended location.

Here's the error that rails give me when I try running $ rake spec

Missing these required gems:
  oauth-plugin   = 0.3.14

You're running:
  ruby 1.8.7.173 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  rubygems 1.3.6 at /Users/eimantas/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.

This is not a single gem that is not being found by rubygems (although it's located where it should be). Any guidance towards the solution is much appreciated.

A: 

Have you tried:

require 'rubygems'
gsiener
Yes. It does not work either.
Eimantas
+2  A: 

Did you previously install oauth?

gem install oauth

It seems it's needed

EDIT:

On your

gem env

you have

RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0]

But if you look at the error it says you are running

ruby 1.8.7.173

Are you pointing to different versions of ruby?

tommasop
hmm.. this must be the cause although I don't understand why gem command installs the gem in one location and then ruby on rails takes different one (I'm certain I have only one version of ruby in my system).
Eimantas
what about "sudo" gem install? Does he have two differents GEM_HOME?
microspino
A: 

First things first: Do you have a config.gem 'oauth-plugin' line in your config/environment.rb file?

If so, try running script/console and type system("gem which oauth-plugin")

Its possible your gem path is messed up from inside your rails app. The above command should tell you if the gem is actually being found by rails.

If it isn't found try system("gem env") from the script/console and see if anything jumps out at you. This should help with debugging.

Lolindrath
I have config.gem 'oauth-plugin' in my environment.rb, but when that line is present - i can't run ./script/console since the gem dependency is not satisifed .( But if I comment it out and run system 'gem which...' i get the correct path to the gem.
Eimantas
+2  A: 

You have two different versions of Ruby installed. First is in:

/usr/bin/ruby

and second one is in:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

The problem is that one is used in command line (i.e. to install gems) and another is used by web server to run Rails.

Since your web server is using second Ruby version one solution would be to install gem using that Ruby version. Alternatively, you can tell your web server to use different Ruby version - depending on which server you are using this can be achieved in different ways.

Slobodan Kovacevic
You can most likely do something like: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem install oauth-plugin to install gem using web server Ruby version.
Slobodan Kovacevic
from the ls -l /usr/lib/ruby it seems that the two versions you are talking about are the same
tommasop
You are right. These two folders have different ruby installed: `% /usr/bin/ruby -vruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0] % /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -vruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]`So if I remove the one in `Ruby.framework` and put a symlink to the first one I should be good.
Eimantas