Skip to content

compatibility problem with latest ruby 2.7.2.137 Windows 10 #1151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AbdulAhadArain opened this issue Dec 26, 2020 · 14 comments
Open

compatibility problem with latest ruby 2.7.2.137 Windows 10 #1151

AbdulAhadArain opened this issue Dec 26, 2020 · 14 comments

Comments

@AbdulAhadArain
Copy link

AbdulAhadArain commented Dec 26, 2020

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 AbdulAhadArain changed the title compatibility problem with latest ruby 2.7 compatibility problem with latest ruby 2.7 Windows 10 Dec 26, 2020
@AbdulAhadArain AbdulAhadArain changed the title compatibility problem with latest ruby 2.7 Windows 10 compatibility problem with latest ruby 2.7.2.137 Windows 10 Dec 26, 2020
@Varsion
Copy link

Varsion commented Jan 17, 2021

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

@AbdulAhadArain
Copy link
Author

AbdulAhadArain commented Jan 17, 2021

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

@jean-francois-labbe
Copy link

I have the same problem, is there any solution?

@y-takey
Copy link

y-takey commented Jan 23, 2021

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

@sjieg
Copy link

sjieg commented Feb 17, 2021

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.

@AbdulAhadArain
Copy link
Author

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
Copy link
Author

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.

@sjieg
Copy link

sjieg commented Mar 9, 2021

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.

@AbdulAhadArain
Copy link
Author

@sjieg still same issue
image

@sjieg
Copy link

sjieg commented Mar 16, 2021

@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'

@AbdulAhadArain
Copy link
Author

@sjieg after uninstalling I got this

image

@sjieg
Copy link

sjieg commented Mar 16, 2021

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

@eduhunter
Copy link

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!

@santigesualdo
Copy link

santigesualdo commented Jan 19, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants