Ruby Cannot Find Installed Gems

I am a little at the end of my mind. I'm on OSX10.6 and my gems are all narrowed. One of the gems I'm trying to use is Hashes. I looked around the internet and several people seemed to have problems with similar problems, but I don’t think they work in my case. Thanks for watching.

All my ruby ​​scripts / gems are installed in / opt / ruby ​​-enterprise-1.8.7-2010.02:

Komputor:~$ which ruby gem irb rails /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby /opt/ruby-enterprise-1.8.7-2010.02/bin/gem /opt/ruby-enterprise-1.8.7-2010.02/bin/irb /opt/ruby-enterprise-1.8.7-2010.02/bin/rails 

And an example gem, hashie (and many others) are installed:

 Komputor:~ $ gem list -l | wc -l 67 Komputor:~ $ gem list | grep hashie hashie (0.4.0) Komputor:gems $ cd /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems Komputor:gems $ ls | grep hashie drwxr-xr-x 13 root admin 442 Nov 24 17:13 hashie-0.4.0 

However, when I try to access them from irb or script, all this fails:

 Komputor:~ $ irb irb(main):001:0> require 'hashie' LoadError: no such file to load -- hashie from (irb):1:in `require' from (irb):1 irb(main):002:0> 

Some environment variables: Gem env:

 Komputor:gems $ gem env RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.0] - INSTALLATION DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby - EXECUTABLE DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/bin - RUBYGEMS PLATFORMS: - ruby - x86-darwin-10 - GEM PATHS: - /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8 - /Users/<snip>/.gem/ruby/1.8 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http://rubygems.org/ 

$ PATH:

 Komputor:gems $ echo $PATH /sw/bin:/sw/sbin:/opt/ruby-enterprise-1.8.7-2010.02/bin:/Applications/android-sdk-1.5/tools:/usr/brlcad/bin:/usr/local/mysql-5.0.67-osx10.5-x86_64/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/mongodb/bin:/sw/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/usr/X11R6/bin 

I will be happy to publish the output of any debug commands.

Thanks for watching!

+6
rubygems
source share
1 answer

As Adam Vandenberg points out, before downloading the gem you need to require "rubygems"

Some frameworks may download this for you, and you can set it to autoload in .irbrc if you like

+12
source share

All Articles