2016-02-08 153 views
0

我已經看到somedifferentanswers,但這些都不幫我...無法加載mysql2寶石

這是招:我有解決這個沒有接觸的Gemfile。我目前正在創建我的工作環境,以便它與生產服務器相匹配,所以我根本無法修改rails的代碼。

我的操作系統:OSX 10.11

紅寶石:紅寶石2.0.0p643

的Rails:4.0.0

創業板的Gemfile中爲gem 'mysql2'。做bundle install時,有沒有錯誤,但是當我嘗試rake db:migrate --trace這是輸出:

rake aborted! 
There was an error while trying to load the gem 'mysql2'. 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler.rb:99:in `require' 
/Users/redar/redar/config/application.rb:7:in `<top (required)>' 
/Users/redar/redar/Rakefile:4:in `require' 
/Users/redar/redar/Rakefile:4:in `<top (required)>' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:75:in `run' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/bin/rake:33:in `<top (required)>' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/rake:23:in `load' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/rake:23:in `<main>' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval' 
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `<main>' 

我不知道如何解釋這一點。 Rakefile有什麼問題嗎?

而且,這是output from the mkmf.log


編輯:這是我的Rake文件的內容,位於MYAPP /文件夾

# Add your own tasks in files placed in lib/tasks ending in .rake, 
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 

require File.expand_path('../config/application', __FILE__) 

MyApp::Application.load_tasks 
+0

我假設你已經在你的系統中安裝了mysql,對吧? (brew安裝mysql) – TopperH

+0

是的,沒錯。 –

+0

看看這個問題:https://github.com/rails/rails/issues/21544,你可能想在你的gemfile中嘗試「gem'mysql2','〜> 0.3.18'」 – TopperH

回答

0

嘗試

bundle exec rake db:migrate 

這將確保您正在執行「rake db:m igrate「,Gemfile中列出的寶石已加載並可用。如果您在沒有「bundle exec」的情況下運行它,那麼您可能只能使用可用的系統寶石執行。

+0

我試過了,但輸出仍然是一樣的。 –