mysql2 icon indicating copy to clipboard operation
mysql2 copied to clipboard

compatibility problem with latest ruby 2.7.2.137 Windows 10

Open AbdulAhadArain opened this issue 4 years ago • 14 comments

Gem::RuntimeRequirementNotMetError: mysql2 requires Ruby version >= 2.2, < 2.7.dev. The current ruby version is 2.7.2.137. An error occurred while installing mysql2 (0.5.3)

AbdulAhadArain avatar Dec 26 '20 05:12 AbdulAhadArain

ok,I have the same problem as you now,and if you solve the problem, can you give me some help?

Varsion avatar Jan 17 '21 04:01 Varsion

I didn't found any solution for this issue and ended up using ubuntu on vm ware because of time constraint

AbdulAhadArain avatar Jan 17 '21 07:01 AbdulAhadArain

I have the same problem, is there any solution?

jean-francois-labbe avatar Jan 21 '21 13:01 jean-francois-labbe

I have the same problem, but I resolved following way.

  1. change ruby version in Gemfile. : ruby '2.7.2'
  2. delete Gemfile.lock and gem installed directory. (e.g. vendor/bundle)
  3. run bundle install

y-takey avatar Jan 23 '21 01:01 y-takey

I suppose it can be many things, for me the main part of the solution was to not use bundler. Just do gem install mysql2.

After this, for me it was not able to complete that step. Which came down to not being able to find all the mysql dll files. Then I started running it with --with-mysql-dir:

gem install mysql2 -- --with-mysql-dir="C:/Program Files/MySQL/Connector C++ 8.0"

But I got the error:

Cannot find library dir(s) C:\Program Files\MySQL\Connector C++ 8.0/lib

Looking into the connector folder, I saw a folder called /lib64/ 💢 . So I just copied this folder en renamed it to /lib/. Probably terrible fix and will bite me in the butt later, but after this the install command completed successfully.

sjieg avatar Feb 17 '21 13:02 sjieg

I suppose it can be many things, for me the main part of the solution was to not use bundler. Just do gem install mysql2.

After this, for me it was not able to complete that step. Which came down to not being able to find all the mysql dll files. Then I started running it with --with-mysql-dir:

gem install mysql2 -- --with-mysql-dir="C:/Program Files/MySQL/Connector C++ 8.0"

But I got the error:

Cannot find library dir(s) C:\Program Files\MySQL\Connector C++ 8.0/lib

Looking into the connector folder, I saw a folder called /lib64/ 💢 . So I just copied this folder en renamed it to /lib/. Probably terrible fix and will bite me in the butt later, but after this the install command completed successfully.

For me this is not ideal as I have other projects (different frameworks) depending on mysql changing the lib folder will break things for all other projects

AbdulAhadArain avatar Feb 18 '21 13:02 AbdulAhadArain

I suppose it can be many things, for me the main part of the solution was to not use bundler. Just do gem install mysql2.

After this, for me it was not able to complete that step. Which came down to not being able to find all the mysql dll files. Then I started running it with --with-mysql-dir:

gem install mysql2 -- --with-mysql-dir="C:/Program Files/MySQL/Connector C++ 8.0"

But I got the error:

Cannot find library dir(s) C:\Program Files\MySQL\Connector C++ 8.0/lib

Looking into the connector folder, I saw a folder called /lib64/ 💢 . So I just copied this folder en renamed it to /lib/. Probably terrible fix and will bite me in the butt later, but after this the install command completed successfully.

I have the same problem, but I resolved following way.

  1. change ruby version in Gemfile. : ruby '2.7.2'
  2. delete Gemfile.lock and gem installed directory. (e.g. vendor/bundle)
  3. run bundle install

I can not downgrade the ruby as the project is already in development before I started work on it.

AbdulAhadArain avatar Feb 18 '21 13:02 AbdulAhadArain

Hello, I have updated from Ruby 2.6 to 2.7 on multiple windows machines with mysql2 now and found a better way to solve it:

  1. Get the mysql installer https://dev.mysql.com/downloads/installer/
  2. Update your tools
  3. When done, you get an overview of the tools you have installed. Make sure Connector/C++ is installed as X86

image

  1. If Connector/C++ is missing click add: MySQL Connectors > Connector/C++ > Connector/C++ 8.0 > Connector/C++ 8.0.23 - X86
  2. Find the folder where Connector C++ installed, likely: C:\Program Files (x86)\MySQL\Connector C++ 8.0
  3. Run the following command in console:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\Program Files (x86)\MySQL\Connector C++ 8.0"

note

  • --platform=ruby will fix the mysql2 requires Ruby version >= 2.2, < 2.7.dev error.
  • -- --with-mysql-dir will fix the problem where mysql2 in failing to get the dll file from the mysql server.

sjieg avatar Mar 09 '21 09:03 sjieg

@sjieg still same issue image

AbdulAhadArain avatar Mar 16 '21 17:03 AbdulAhadArain

@AbdulAhadArain looks like it was already installed. maybe try gem uninstall mysql2 and try again.

It might also help.to set your gemfile dependency to gem 'mysql2', '~> 0.5.3'

sjieg avatar Mar 16 '21 18:03 sjieg

@sjieg after uninstalling I got this

image

AbdulAhadArain avatar Mar 16 '21 18:03 AbdulAhadArain

You have an > at the end of the path to your c++ connector folder. Make sure the path is valid and exists.

sjieg avatar Mar 16 '21 18:03 sjieg

Hello, I have updated from Ruby 2.6 to 2.7 on multiple windows machines with mysql2 now and found a better way to solve it:

  1. Get the mysql installer https://dev.mysql.com/downloads/installer/
  2. Update your tools
  3. When done, you get an overview of the tools you have installed. Make sure Connector/C++ is installed as X86

image

  1. If Connector/C++ is missing click add: MySQL Connectors > Connector/C++ > Connector/C++ 8.0 > Connector/C++ 8.0.23 - X86
  2. Find the folder where Connector C++ installed, likely: C:\Program Files (x86)\MySQL\Connector C++ 8.0
  3. Run the following command in console:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\Program Files (x86)\MySQL\Connector C++ 8.0"

note

  • --platform=ruby will fix the mysql2 requires Ruby version >= 2.2, < 2.7.dev error.
  • -- --with-mysql-dir will fix the problem where mysql2 in failing to get the dll file from the mysql server.

Worked liked a charm! Thanks!

eduhunter avatar Aug 09 '21 19:08 eduhunter

Thanx for the help!! These are my notes about this:

How to install gem mysql2 0.5.3 with ruby 2.7.3 on windows 10.

1- Downloaded only mysql connector for c++ 8.0 , from here : https://dev.mysql.com/downloads/connector/cpp/ 2- From there select x32 and zip file. 3- Create folder on C:\Program Files (x86)\MySQL\Connector C++ 8.0 4- Extract zip content on folder from step 3. 5- Open ruby cmd and run: gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\Program Files (x86)\MySQL\Connector C++ 8.0" 6- From there the latest version of mysql2 was installed. (0.5.3)

Note: If version error still showing, remove Gemfile.lock, and run first 'bundle install' and the 'bundle update --bundler' Thanks and good luck!

santigesualdo avatar Jan 19 '22 23:01 santigesualdo