2014-08-28 79 views
0

我使用Homebrew安裝MySQL(brew install mysql),然後運行$ gem install mysql2。我在運行OSX 10.9.4的Mac上。不能耙:數據庫遷移 - 繼續獲取'耙子中止!加載錯誤'

我改變目錄到我的應用程序的根目錄,然後嘗試運行rake db:migrate命令,得到這個錯誤:

Levine_iMac$ rake db:migrate 
rake aborted! 
LoadError: dlopen(/Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method 
    Referenced from: /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle 
    Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib 
in /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle 
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in require' 
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in <top (required)>' 
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in <top (required)>' 
(See full trace by running task with --trace) 
Levine_iMac$ 

我嘗試添加點東西給我的.bash_profile,如描述here,但那沒用。

我嘗試了一個sudo命令,如here所述,但這並不奏效。

然後我試圖從2.1.1更新我的Ruby版本.. 2.1.2 ..,當我運行rake現在我收到此錯誤:DB上遷移

Levine_iMac$ rake db:migrate rake aborted! cannot load such file -- bundler/setup /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/boot.rb:4:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:1:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in '<top (required)>' (See full trace by running task with --trace) Levine_iMac$ bundle install rbenv: bundle: command not found The 'bundle' command exists in these Ruby versions: 2.1.1 Levine_iMac$

任何想法如何補救這個?謝謝。

+0

我試過了。現在我運行rake時出現這個錯誤:db migrate 'Levine_iMac $ rake db:migrate rake aborted! 無法加載此文件 - 打包程序/設置 /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/boot.rb:4:in'' /Users/Levine_iMac/Dropbox/Coding /Sandbox/simple_cms2/config/application.rb:1:in'' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in'' (通過運行帶有--trace任務查看完整的跟蹤) Levine_iMac $捆綁安裝 rbenv:包:找不到命令 的「捆綁」命令在這些Ruby版本存在: 2.1.1' – HPJAJ 2014-08-28 18:01:08

+0

有一個線索在最後line:「找不到命令'bundle'命令存在於這些Ruby版本中:2.1.1」。試試'gem install bundler'(升級紅寶石後需要)。 – cydparser 2014-08-28 20:09:28

+0

工作。謝謝@paulwise!感謝所有貢獻的人。 – HPJAJ 2014-08-28 20:42:11

回答

0

那麼,當你運行rake db時,你準確地期望發生什麼:migrate?下一步將爲您實現嗎?如果你能回答這個問題,你就會明白爲什麼你做的事情沒有意義。

我會詳細說明:

耙分貝:遷移只能在現有的Rails應用程序的環境。運行'gem install mysql2'會在你的計算機上爲你獲得這個庫(這個命令本身執行,它實際上與Rails本身沒有任何關係,或者需要Rails應用程序用於上下文)。所以,兩者之間沒有線性關係。

  1. 軌新的myapp在Gemfile中
  2. 添加 '寶石mysql2'
  3. 耙分貝:創建

,或者:

rails new myapp -d mysql 
+0

什麼讓你覺得他不在現有的Rails應用程序中? – JTG 2014-08-28 17:52:45

+0

無論他是否與他無關,因爲'gem install mysql2'是一個與Rails應用程序無關的命令,它只是將庫安裝到您的計算機。運行rake db:在安裝mysql2之前和之後在他的應用程序中遷移,將會輸出相同的結果。 – ilrein 2014-08-28 17:58:46

+0

你好。我確實有一個現有的Rails應用程序,我一直在另一臺計算機上工作。我在這臺計算機上安裝了所有東西,創建了相同的命名數據庫,並且需要遷移來填充它。這是我得到錯誤的地方。 我試過上面再次安裝Ruby的建議(由by,是從2.1.1 ..升級到2.1.2 ..)。現在我得到一個新的錯誤(上圖)。 謝謝。 – HPJAJ 2014-08-28 18:07:07