Question

I am using mysql2 gem and for some reason I am not able to run the rails server command. I have tried all the solutions found in stackoverflow, but nothing seems to work. Here is the output.

$ rails s
/Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in `require': dlopen(/Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/mysql2-0.3.15/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/mysql2-0.3.15/mysql2/mysql2.bundle
  Reason: image not found - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/mysql2-0.3.15/mysql2/mysql2.bundle
    from /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in `<top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:76:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:72:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:72:in `block in require'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:61:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:61:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler.rb:131:in `require'
    from /Users/user/Desktop/simple_cms/basic_cms/config/application.rb:7:in `<top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:74:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:74:in `block in <top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:71:in `tap'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
Was it helpful?

Solution 2

Thanks for the help everyone. I did find the solution although I don't really know how to explain it. Here is what I did.

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

OTHER TIPS

Try adding this to your .bash_profile

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top