在我的档案中,我有:
gem 'mysql2'
我的数据库.yml如下:
default: &default
adapter: mysql2
database: <%= ENV['db_name'] %>
username: <%= ENV['db_user'] %>
password: <%= ENV['db_pass'] %>
host: <%= ENV['db_host'] %>
pool: 32
socket: <%= ENV['socket'] %>
development:
<<: *default
production:
<<: *default
我已经运行了bundle update
和bundle install
以及我的Gemfile.锁显示mysql2.
然而,当我运行rake db:migrate
时,我在我的计算机和登台服务器上都会看到:
myproject.com(master)$ rake db:migrate
WARNING: Use strings for Figaro configuration. 10000012508 was converted to "10000012508".
WARNING: Use strings for Figaro configuration. 860526407370038 was converted to "860526407370038".
rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
.....
为了确保mysql2的版本没有问题,我做了bundle clean --force
次,又运行了bundle install
次和bundle update
次,当我运行gem list
次时,我看到了mysql2 (0.4.0)
次,没有其他版本.
任何 idea 都将不胜感激.
解决方案
这是Rails 4.1目前的一个问题.x和4.2.x、 根据这bug report条,它将在rails 4.2的下一版本中修复.x(链接注释中的dcorr).
同时,您可以通过将这一行添加到您的文件中,将mysql2降级到0.3.18版本来进行修复:
gem 'mysql2', '~> 0.3.18'