简体   繁体   中英

ruby on rails mac x os lion run server LoadError

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

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM