问题
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