Rails on OS X: no such file to load — mysql

Just a quick post to maybe help someone who has a similar problem:

I had the following error whenever I tried to use ‘script/console’ (script/server and rake worked fine)

require ‘mysql’

MissingSourceFile: no such file to load — mysql
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require’

Turns out I had multiple versions of RubyGems installed on my Macbook. The error message already spoils it by saying rubygems in /System/Library/Framework/ is being called, while I actually installed rubygems manually in a different folder.

To prevent these kind of problems in the future I simply deleted the entire Ruby.framework directory and use the manually installed versions instead.

2 thoughts on “Rails on OS X: no such file to load — mysql

  1. Did you alter the symlinks in /usr/bin? /usr/bin/ruby for example should link to /opt/local/bin/ruby if you’re using MacPorts ruby.

  2. Well ‘which ruby’ pointed to the right one in /opt/local/bin, ‘which gem’ pointed to the right one as well. Only when I launched ‘script/console’ the wrong rubygems got loaded.

Leave a Reply

Your email address will not be published.