When I require certain gems, some of them work and some of them don't work. They seem to install find and I can do a gem list and they are there. However, when I try to run them in Irb or run my ruby programs from the terminal I get the following:
LoadError: no such file to load -- sanitize
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:54:in `gem_original_require'
And so I followed the guide on RubyGems and everything seems fine:
noahclark$ gem list sanitize
*** LOCAL GEMS ***
sanitize (2.0.3)
noahclark$ ruby -rubygems -e 'require "sanitize"'
noahclark$
noahclark$ which ruby
/opt/local/bin/ruby
noahclark$ gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /opt/local/bin/ruby
So then I tried:
noahclark$ which gem
/opt/local/bin/gem
noahclark$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /Users/noahclark/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
You can see that which gem and gem environment are looking at two separate directories. I hunted around for a fix and I could only find something that suggested adding export PATH=$PATH:/opt/local/bin/gem to my .bashrc file. This did not fix it.
How should I go about fixing this?