3

When I type the rails server on terminal, I got the following error. I don't know how to fix it. Is any one can give me a help? And I also need a ruby on rails mac os x Lion installation tutorial.

:simple_cms benhuayang$ rails server
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require':
dlopen(/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)  
Referenced from:
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found -
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle   from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `<top (required)>'    from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'     from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'     from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'    from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'    from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'    from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'     from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'    from
/Users/benhuayang/Sites/simple_cms/config/application.rb:7:in `<top (required)>' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'     from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:53:in `block in '   from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'     from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>'  from
script/rails:6:in `require'     from
script/rails:6:in `<main>'

this is path for mysql

/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/bin:/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0@global/bin:/Users/benhuayang/.rvm/rubies/ruby-1.9.3-p0/bin:/Users/benhuayang/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
4
  • What is the path to your mysql installation? Commented Feb 8, 2012 at 22:07
  • Hi,how to check the path on mac os x ? Commented Feb 9, 2012 at 8:25
  • What process did you use to install MySQL? You might be able to do a which mysql from the terminal to get the path. Commented Feb 9, 2012 at 8:56
  • I just found the the path for mysql. Commented Feb 9, 2012 at 9:24

2 Answers 2

6

When I've run into this in the past, I've used the following solution.

In the terminal, run:

export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib"

Then try running your rails server command in the root of your app. If it works, just put that same command into your ~/.profile so that it runs each time you enter the terminal.

Sign up to request clarification or add additional context in comments.

Comments

0

Ryan's solution worked for me when I had the following error after running rake db:migrate, I figured posting it will help with the google search.

rake aborted!
dlopen(/Users/[USERNAME]/.rvm/gems/ruby-1.9.3-p286/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Users/[USERNAME]/.rvm/gems/ruby-1.9.3-p286/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/[USERNAME]/.rvm/gems/ruby-1.9.3-p286/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle

(See full trace by running task with --trace)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.