brianmario / mysql2

A modern, simple and very fast Mysql library for Ruby - binding to libmysql
http://github.com/brianmario/mysql2
MIT License
2.24k stars 547 forks source link

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

Open dsjm1 opened 3 years ago

dsjm1 commented 3 years ago

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.

mariano-dm commented 3 years ago

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:inblock in find_library': undefined method split' for nil:NilClass (NoMethodError)\n\tfrom /usr/local/lib/ruby/2.7.0/mkmf.rb:1050:incollect'\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",`

AdoPi commented 3 years ago

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

mariano-dm commented 3 years ago

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

pcopissa commented 2 years ago

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.

vdwivedi-mdsol commented 11 months ago

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.

afweb20 commented 10 months ago

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  
SunnyChaware commented 10 months ago

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..??

AndreiIlisei commented 9 months ago

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