mysql2 icon indicating copy to clipboard operation
mysql2 copied to clipboard

Unable to use MySql2 on Windows with Ruby 2.7.2 or 3.0.0 - Can we expect an update ?

Open dsjm1 opened this issue 3 years ago • 8 comments

I am wanting to use MySql with ruby 2.7 & 3.0 (a pre-req to the soon to be released Rails 7.0 version). I need to go to Rails 7.0 because Webpacker in Rails 6.0 is a mess (apps can work in dev env but the js assets don't seem to get created in prd env (prd precompile fails to generate the assets folder !). Webpacker is the new Rails way to manage assets but is split between javascript assets & other assets. Webpacker manages the javascript while the older mechanism manages the other assets (images & stylesheets).
As said, it is a mess !. Nearly impossible to find any intelligent support.

But on to MySql2 and ruvy 2.7.2 + 3.0.0

Below is what happens in these versions of Ruby (this was in 2.7.2) ...

Fetching gem metadata from https://rubygems.org/............. Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Bundler found conflicting requirements for the Ruby version: In Gemfile: Ruby (~> 2.7.2.0) x64-mingw32

mysql2 (~> 0.5) x64-mingw32 was resolved to 0.5.2, which depends on
  Ruby  (< 2.6, >= 2.0) x64-mingw32
     run  bundle binstubs bundler

Could not find gem 'mysql2 (~> 0.5) x64-mingw32' in any of the gem sources listed in your Gemfile. rails webpacker:install Could not find gem 'mysql2 (~> 0.5) x64-mingw32' in any of the gem sources listed in your Gemfile. Run bundle install to install missing gems.


(I tried setting gemfile entry to 0.5.3 but same problem).

Is this a simple matter of an update to mysql2 ?

Hoping someone has an answer.

dsjm1 avatar Mar 29 '21 02:03 dsjm1

I'm trying to install it in ruby 2.7 centos, installed gcc and devel, no luck, is this possible ?

"gem install mysql2 -v 0.5.3 --no-document -- --srcdir=/usr/include/mysql",

"/usr/local/lib/ruby/2.7.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError)",
    googlecompute:         "\tfrom /usr/local/lib/ruby/2.7.0/mkmf.rb:1050:in `collect'",
    googlecompute:         "\tfrom /usr/local/lib/ruby/2.7.0/mkmf.rb:1050:in `find_library'",
    googlecompute:         "\tfrom extconf.rb:87:in `<main>'",
    googlecompute:         "",

stderr": "ERROR: Error installing mysql2:\n\tERROR: Failed to build gem native extension.\n\n current directory: /home/sensu/.gem/gems/mysql2-0.5.3/ext/mysql2\n/usr/local/bin/ruby -I /usr/local/lib/ruby/2.7.0 -r ./siteconf20210604-25440-11wbthq.rb extconf.rb --srcdir\\=/usr/include/mysql\nchecking for rb_absint_size()... yes\nchecking for rb_absint_singlebit_p()... yes\nchecking for rb_wait_for_single_fd()... yes\n*** extconf.rb failed ***\nCould not create Makefile due to some reason, probably lack of necessary\nlibraries and/or headers. Check the mkmf.log file for more details. You may\nneed configuration options.\n\nProvided configuration options:\n\t--with-opt-dir\n\t--without-opt-dir\n\t--with-opt-include\n\t--without-opt-include=${opt-dir}/include\n\t--with-opt-lib\n\t--without-opt-lib=${opt-dir}/lib\n\t--with-make-prog\n\t--without-make-prog\n\t--srcdir=.\n\t--curdir\n\t--ruby=/usr/local/bin/$(RUBY_BASE_NAME)\n\t--with-mysql-dir\n\t--without-mysql-dir\n\t--with-mysql-include\n\t--without-mysql-include=${mysql-dir}/include\n\t--with-mysql-lib\n\t--without-mysql-lib=${mysql-dir}/lib\n\t--with-mysql-config\n\t--without-mysql-config\n\t--with-mysqlclient-dir\n\t--without-mysqlclient-dir\n\t--with-mysqlclient-include\n\t--without-mysqlclient-include=${mysqlclient-dir}/include\n\t--with-mysqlclient-lib\n\t--without-mysqlclient-lib=${mysqlclient-dir}/lib\n\t--with-mysqlclientlib\n\t--without-mysqlclientlib\n/usr/local/lib/ruby/2.7.0/mkmf.rb:1050:in block in find_library': undefined method split' for nil:NilClass (NoMethodError)\n\tfrom /usr/local/lib/ruby/2.7.0/mkmf.rb:1050:in collect'\n\tfrom /usr/local/lib/ruby/2.7.0/mkmf.rb:1050:in find_library'\n\tfrom extconf.rb:87:in

'\n\nTo see why this extension failed to compile, please check the mkmf.log which can be found here:\n\n /home/sensu/.gem/extensions/x86_64-linux/2.7.0-static/mysql2-0.5.3/mkmf.log\n\nextconf failed, exit code 1\n\nGem files will remain installed in /home/sensu/.gem/gems/mysql2-0.5.3 for inspection.\nResults logged to /home/sensu/.gem/extensions/x86_64-linux/2.7.0-static/mysql2-0.5.3/gem_make.out",`

mariano-dm avatar Jun 04 '21 18:06 mariano-dm

Hi, do you have libmariadb-dev or libmariadbclient-dev installed? I think it could solve your issue 😄

AdoPi avatar Jun 15 '21 08:06 AdoPi

I solved it by using the old mysql community yum install --setopt=obsoletes=0 -y mysql-community-devel mysql-community-client

mariano-dm avatar Jun 17 '21 16:06 mariano-dm

I had a similar issue (failure in line 1050 or 1771 of mkmf.rb, with Ruby 2.7.3 from Ruby Installer on Windows). See issue #1210 on how I solved it.

pcopissa avatar Nov 11 '21 10:11 pcopissa

I am having similar issue with Ruby version ruby-3.2.1. in mac OS ventura An error occurred while installing mysql2 (0.5.5), and Bundler cannot continue.

vdwivedi-mdsol avatar Sep 14 '23 13:09 vdwivedi-mdsol

I am having similar issue with Ruby version ruby-3.2.1. in mac OS ventura An error occurred while installing mysql2 (0.5.5), and Bundler cannot continue.

I had the same problem in Mac OS Ventura. Try brew install mysql before installing gem. It worked for me.

1. brew install mysql 
2. gem install mysql2  

afweb20 avatar Oct 06 '23 15:10 afweb20

I am having similar issue with Ruby version ruby-3.2.1. in mac OS ventura An error occurred while installing mysql2 (0.5.5), and Bundler cannot continue.

I had the same problem in Mac OS Ventura. Try brew install mysql before installing gem. It worked for me.

1. brew install mysql 
2. gem install mysql2  

i did the same but still it is showing the same error

An error occurred while installing mysql2 (0.5.5), and Bundler cannot
continue.

In Gemfile:
  mysql2

any suggestions..??

SunnyChaware avatar Oct 07 '23 11:10 SunnyChaware

I am having similar issue with Ruby version ruby-3.2.1. in mac OS ventura An error occurred while installing mysql2 (0.5.5), and Bundler cannot continue.

I had the same problem in Mac OS Ventura. Try brew install mysql before installing gem. It worked for me.

1. brew install mysql 
2. gem install mysql2  

i did the same but still it is showing the same error

An error occurred while installing mysql2 (0.5.5), and Bundler cannot
continue.

In Gemfile:
  mysql2

any suggestions..??

doing the 1. brew install mysql and then bundle install gem made it work for me

AndreiIlisei avatar Nov 09 '23 13:11 AndreiIlisei