2012-02-08 118 views
2

當我在終端上鍵入rails服務器時,出現以下錯誤。 我不知道如何解決它。有人可以幫我嗎? 而且我還需要一個Ruby on Rails的Mac OS X Lion安裝教程。ruby​​ on rails mac x os獅子運行服務器LoadError

 
: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/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'  from 
/Users/benhuayang/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'  from 
/Users/benhuayang/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each' from 
/Users/benhuayang/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require' from 
/Users/benhuayang/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each' from 
/Users/benhuayang/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'  from 
/Users/benhuayang/.rvm/gems/[email protected]/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>' 

這是MySQL

/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/bin:/Users/benhuayang/.rvm/gems/[email protected]/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 
+0

什麼是你的mysql安裝路徑? – Ryan 2012-02-08 22:07:32

+0

嗨,如何檢查mac os x上的路徑? – Ben 2012-02-09 08:25:08

+0

你用什麼過程來安裝MySQL?你可能能夠從終端執行'哪個mysql'來獲取路徑。 – Ryan 2012-02-09 08:56:31

回答

5

當我已經在過去碰上了這條路,我用以下解決方案。

在終端,運行:

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

然後嘗試在你的應用程序的根目錄運行你rails server命令。如果它起作用,只需將相同的命令放入您的〜/ .profile中,以便它每次進入終端時都會運行。

+0

謝謝你。幫助我 – Ben 2012-02-21 00:38:25

+0

此解決方案運作良好 – 2012-04-13 07:32:42

0

瑞安的解決方案爲我工作,當我運行耙分貝後出現以下錯誤:遷移,我想通發佈將與谷歌的搜索幫助。

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)