2012-03-25 51 views
3

我一直無法得到mysql2適配器與最新版本的rails工作。我剛生成一個新項目。增加了以下我的Gemfile:Rails 3.2.2 mysql2適配器錯誤

​​

那當然跑:

bundle install 

我也修改了我的database.yml文件:

development: 
    adapter: mysql2 
    encoding: utf8 
    database: blog_development 
    username: root 
    password: ********* 
    socket: /tmp/mysql.sock 

test: 
    adapter: mysql2 
    encoding: utf8 
    database: blog_test 
    username: root 
    password: ******** 
    socket: /tmp/mysql.sock 

production: 
    adapter: mysql2 
    encoding: utf8 
    database: blog_production 
    username: root 
    password: ********* 
    socket: /tmp/mysql.sock 

所以當我嘗試和運行耙分貝:創建,以下是輸出。

$ rake db:create --trace 
** Invoke db:create (first_time) 
** Invoke db:load_config (first_time) 
** Invoke rails_env (first_time) 
** Execute rails_env 
** Execute db:load_config 
** Execute db:create 
rake aborted! 
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (can't activate mysql2 (~> 0.3.10), already activated mysql2-0.3.6. Make sure all dependencies are added to Gemfile.) 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/rubygems_integration.rb:157:in `block in replace_gem' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<top (required)>' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:48:in `resolve_hash_connection' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:127:in `establish_connection' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:67:in `create_database' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:40:in `block (3 levels) in <top (required)>' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:40:in `each' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:40:in `block (2 levels) in <top (required)>' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain' 
/Users/teddyknox/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `load' 
/Users/teddyknox/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `<main>' 
Tasks: TOP => db:create 

它告訴我安裝:

gem install activerecord-mysql2-adapter 

但這種寶石不存在。我很困惑。我已經嘗試了很多不同版本的mysql2,但都沒有任何效果。有任何想法嗎?

回答

3

它看起來像你的寶石中的一種需要mysql2 ~> 0.3.10(意思> = 0.3.10 & & < 0.4),而你需要它< 0.3.7。請嘗試再次刪除版本上的約束,並再次刪除該約束嗎?

+1

似乎有mysql2版本範圍的一個小窗口,與軌道3.2.2兼容。我可能剛剛發現它與「mysql2」,「〜> 0.3.11」。 – Teddy 2012-03-25 17:05:17

11

使用中的Gemfile以下似乎工作:

gem "mysql2", "~> 0.3.11" 
相關問題