Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby gem not found although it is installed

Tags:

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:

Installation

% 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.

like image 906
Eimantas Avatar asked May 09 '10 08:05

Eimantas


People also ask

Where are my RubyGems installed?

When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.

How do you check if I have a gem installed?

Since your goal is to verify a gem is installed with the correct version, use gem list . You can limit to the specific gem by using gem list data_mapper . To verify that it's installed and working, you'll have to try to require the gem and then use it in your code.

How do I know if Ruby is installed on Windows?

First, check if you already have Ruby installed. Open the command prompt and type ruby -v. If Ruby responds, and if it shows a version number at or above 2.2. 2, then type gem --version.

Where are RubyGems installed Mac?

By default, binaries installed by gem will be placed into: /usr/local/lib/ruby/gems/3.1. 0/bin You may want to add this to your PATH.


1 Answers

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.

like image 94
Slobodan Kovacevic Avatar answered Oct 15 '22 21:10

Slobodan Kovacevic