1

I am facing a mysql2 gem version error while trying to create a new RailsApps example application using Rails Composer. For example, while creating a rails-devise-roles example with the following command:

$ rails new rails-devise-roles -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

The error is:

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. (Gem::LoadError)

The messages on the console indicate mysql2 version 0.3.21 is pulled in

run bundle install --without production from "."
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
...................
Using mysql2 0.3.21

The generated Gemfile has

gem 'mysql2', '~> 0.3.18'

I am using ruby 2.5.3 and Rails 5.2.1

user1575148
  • 561
  • 6
  • 28
  • Please show the full error. Which gem says it requires `mysql2 (< 0.6.0, >= 0.4.4)`, in the error message? Please show (a minimal sample from) the `Gemfile` and `Gemfile.lock`. Which gems do you have that depend on `mysql2`? – Tom Lord Nov 12 '18 at 10:51
  • Actually scratch that, I googled the project and the top issue reported is the same as your error: https://github.com/RailsApps/rails-composer/issues/279 – Tom Lord Nov 12 '18 at 10:54
  • 2
    A [quick qorkaround](https://github.com/RailsApps/rails-composer/issues/279#issuecomment-422095200) is to run the installer with SQLite, then switch it out for `mysql` after the initial step. Or to fix it properly, someone needs to update that project. – Tom Lord Nov 12 '18 at 10:58
  • @TomLord Yes, I went with that work around. – user1575148 Nov 19 '18 at 04:54

0 Answers0