Error loading the 'mysql2' Active Record adapter

风格不统一 提交于 2020-05-16 04:16:49

问题


I am trying to upgrade my app and this is the error I am getting while deploying the app:

Error loading the 'mysql2' Active Record adapter. Missing a gem it depends on? can't activate mysql2 (< 0.6.0, >= 0.4.4), already activated mysql2-0.3.21. Make sure all dependencies are added to Gemfile.

here is my Gemfile: https://github.com/BI-CTSICN/sparc-request/blob/master/Gemfile

 gem 'mysql2', '~> 0.3.18'
 gem 'rails', '~> 5.1', '>= 5.1.4'

I am using ruby 2.4.2


回答1:


Your mysql2 version you use (0.3.21, checked in Gemfile.lock) is too old, required one is newer than 0.4.4.

Upgrade your mysql2 gem by changing version in Gemfile and running bundle update mysql2. Of course before that check what changed between versions and then run your tests to check if upgrade didn't break anything.




回答2:


Just lock the mysql2 gem version not work for me. The only thing that work was match the rails gem version with mysql2 gem version, comparing both by it's release date.

Ex: I'm updating now my rails version from 5.1 to 5.2, so I want to put mysql 0.5.3 on my application (the most recent version). But I can put only the 0.4.10 version, because of it's release date match with rails 5.2.0.rc2 version that I installed right now (both are from march, 2018, with one day of difference).

I don't know why this working, but I guess that's a incompatibility problem between the rails and mysql2 versions that I tried to install.



来源:https://stackoverflow.com/questions/54569794/error-loading-the-mysql2-active-record-adapter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!