mysql2
mysql2 copied to clipboard
compatibility problem with latest ruby 2.7.2.137 Windows 10
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)
ok,I have the same problem as you now,and if you solve the problem, can you give me some help?
I didn't found any solution for this issue and ended up using ubuntu on vm ware because of time constraint
I have the same problem, is there any solution?
I have the same problem, but I resolved following way.
- change ruby version in Gemfile. :
ruby '2.7.2'
- delete Gemfile.lock and gem installed directory. (e.g.
vendor/bundle
) - run
bundle install
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 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
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.
- change ruby version in Gemfile. :
ruby '2.7.2'
- delete Gemfile.lock and gem installed directory. (e.g.
vendor/bundle
)- run
bundle install
I can not downgrade the ruby as the project is already in development before I started work on it.
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:
- Get the mysql installer https://dev.mysql.com/downloads/installer/
- Update your tools
- When done, you get an overview of the tools you have installed. Make sure Connector/C++ is installed as X86
- If Connector/C++ is missing click add: MySQL Connectors > Connector/C++ > Connector/C++ 8.0 > Connector/C++ 8.0.23 - X86
- Find the folder where Connector C++ installed, likely:
C:\Program Files (x86)\MySQL\Connector C++ 8.0
- 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 wheremysql2
in failing to get the dll file from the mysql server.
@sjieg still same issue
@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 after uninstalling I got this
You have an >
at the end of the path to your c++ connector folder. Make sure the path is valid and exists.
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:
- Get the mysql installer https://dev.mysql.com/downloads/installer/
- Update your tools
- When done, you get an overview of the tools you have installed. Make sure Connector/C++ is installed as X86
- If Connector/C++ is missing click add: MySQL Connectors > Connector/C++ > Connector/C++ 8.0 > Connector/C++ 8.0.23 - X86
- Find the folder where Connector C++ installed, likely:
C:\Program Files (x86)\MySQL\Connector C++ 8.0
- 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 wheremysql2
in failing to get the dll file from the mysql server.
Worked liked a charm! Thanks!
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!