noizZze

Gem Is in the List but Doesn't Load

Here’s another quick tip. If you can see a gem in the list of your installed gems

1
2
3
4
5
→ gem list mysql

*** LOCAL GEMS ***

mysql (2.8.1)

… but when you try loading it, it doesn’t work

1
2
3
4
5
6
→ irb
>> require 'mysql'
LoadError: no such file to load -- mysql
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
  from (irb):1

… make sure that you don’t have stale Gem specifications hanging around in the Gem paths. Sometimes you have a Gem installed in the system folder (/Library/Ruby/Gems/1.8), but a stale Gem specification (for example, mysql-2.8.1.gemspec) sitting in your local user Gem folder (~/.gem/ruby/1.8). Remove the stale spec and you are golden.