1

I know these questions has been answered before but i cant start the rails server that i have set up. Someone posted the exact same error here Unable to start rails server but i cant get it to work with the answer. I'm really new at all this so help would be greatly appreciated.

/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib (LoadError)
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
  Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
    from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
    from /Users/valentin/Sites/simple_cms/config/application.rb:7
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
    from script/rails:6:in `require'
    from script/rails:6

Im running: mySQL: 5.5.11

rails: 3.0.7

ruby:1.8.7

gems: 1.7.2

mySQL2: 0.2.7

Can anyone please help? Thanks!

Community
  • 1
  • 1
KidKola
  • 291
  • 1
  • 3
  • 4
  • Possible duplicate of: http://stackoverflow.com/questions/4546698/library-not-loaded-libmysqlclient-16-dylib-error-when-trying-to-run-rails-serve – Wes Apr 22 '11 at 02:10
  • @Wes - Thanks! tried that, no luck! – KidKola Apr 22 '11 at 02:25

1 Answers1

1

Neither of the other links were the same problem as yours, both of those problems were with older mysql2 gems that didn't have the full path to libmysqlclient.16.dylib in the bundle, notice that your error has the full path, Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib (the other questions did not have that).

Your problem is that that lib probably doesn't exist because that's not where MySQL will be installed in most OSX systems.

Assuming that you've installed MySQL you should have a command called mysql_config - you want to install your gem by pointing the installer at this file. The installed can then use the output from mysql_config to find the right place for all the MySQL libs it needs.

Bored and just want the answer?

sudo gem install mysql2 -- --with-mysql-config=`which mysql_config`
smathy
  • 26,283
  • 5
  • 48
  • 68
  • Hey, Jason, I appreciate you taking the time to explain this. It definitely helps me understand it better. I found the answer right here. I was following the Linda.com tutorial too so obviously is a common problem http://stackoverflow.com/questions/5690200/ruby-on-rails-3-and-webrick-issue. I wanted to post this earlier but I couldn't post an answer to my own question for the first 8 hours. Thanks again for your help. – KidKola Apr 22 '11 at 23:13