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 550 forks source link

error installing, ruby 3.0.2p107, win10 #1265

Open AdiLovee opened 2 years ago

AdiLovee commented 2 years ago
PS G:\development\RUBY\code> gem install mysql2 -v 0.5.4
Temporarily enhancing PATH for MSYS/MINGW...
Installing required msys2 packages: mingw-w64-x86_64-libmariadbclient
error: mingw-w64-x86_64-c-ares: signature from "David Macek <david.macek.0@gmail.com>" is unknown trust
error: mingw-w64-x86_64-brotli: signature from "David Macek <david.macek.0@gmail.com>" is unknown trust
error: mingw-w64-x86_64-p11-kit: signature from "David Macek <david.macek.0@gmail.com>" is unknown trust
error: mingw-w64-x86_64-jansson: signature from "David Macek <david.macek.0@gmail.com>" is unknown trust
error: mingw-w64-x86_64-xz: signature from "David Macek <david.macek.0@gmail.com>" is unknown trust
error: failed to commit transaction (invalid or corrupted package)
pacman failed with the following output:
resolving dependencies...
looking for conflicting packages...

Packages (19) mingw-w64-x86_64-brotli-1.0.9-2  mingw-w64-x86_64-c-ares-1.17.1-1  mingw-w64-x86_64-ca-certificates-20200601-3  mingw-w64-x86_64-curl-7.77.0-2  mingw-w64-x86_64-jansson-2.13.1-1  mingw-w64-x86_64-jemalloc-5.2.1-2  mingw-w64-x86_64-libffi-3.3-4  mingw-w64-x86_64-libidn2-2.3.1-1  mingw-w64-x86_64-libmetalink-0.1.3-3  mingw-w64-x86_64-libpsl-0.21.1-3  mingw-w64-x86_64-libssh2-1.9.0-3  mingw-w64-x86_64-libtasn1-4.17.0-1  mingw-w64-x86_64-libunistring-0.9.10-4  mingw-w64-x86_64-libxml2-2.9.12-1  mingw-w64-x86_64-nghttp2-1.43.0-1  mingw-w64-x86_64-openssl-1.1.1.k-2  mingw-w64-x86_64-p11-kit-0.23.22-1  mingw-w64-x86_64-xz-5.2.5-2  mingw-w64-x86_64-libmariadbclient-3.1.12-1

Total Download Size:     1.33 MiB
Total Installed Size:  106.03 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
 mingw-w64-x86_64-c-ares-1.17.1-1-any downloading...
 mingw-w64-x86_64-brotli-1.0.9-2-any downloading...
 mingw-w64-x86_64-p11-kit-0.23.22-1-any downloading...
 mingw-w64-x86_64-jansson-2.13.1-1-any downloading...
 mingw-w64-x86_64-xz-5.2.5-2-any downloading...
checking keyring...
checking package integrity...
:: File /var/cache/pacman/pkg/mingw-w64-x86_64-c-ares-1.17.1-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
:: File /var/cache/pacman/pkg/mingw-w64-x86_64-brotli-1.0.9-2-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
:: File /var/cache/pacman/pkg/mingw-w64-x86_64-p11-kit-0.23.22-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
:: File /var/cache/pacman/pkg/mingw-w64-x86_64-jansson-2.13.1-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
:: File /var/cache/pacman/pkg/mingw-w64-x86_64-xz-5.2.5-2-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
Errors occurred, no packages were upgraded.
Building native extensions. This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.4/ext/mysql2
C:/Ruby30-x64/bin/ruby.exe -I C:/Ruby30-x64/lib/ruby/3.0.0 -r ./siteconf20220524-10328-br0hw9.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enc_interned_str() in ruby.h... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby30-x64/bin/$(RUBY_BASE_NAME)
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysql-config
        --without-mysql-config
        --with-mysqlclient-dir
        --without-mysqlclient-dir
        --with-mysqlclient-include
        --without-mysqlclient-include=${mysqlclient-dir}/include
        --with-mysqlclient-lib
        --without-mysqlclient-lib=${mysqlclient-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib
C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError)
        from C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `collect'
        from C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `find_library'
        from extconf.rb:103:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/mysql2-0.5.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.4 for inspection.
Results logged to C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/mysql2-0.5.4/gem_make.out

mkmf.log

atsalolikhin-spokeo commented 2 years ago

@JayeLovee I had the same sort of issue and was able to resolve it by installing MySQL development package. See #1266 .

rawlingsr commented 2 years ago

I was getting the same error. I was able to resolve it by installing a compatible connector for windows.

https://mariadb.com/downloads/connectors/

I did a typical install, and then installed the gem with the following command:

gem install mysql2 -- --with-mysql-dir="C:\Program Files\MariaDB\MariaDB Connector C 64-bit"

dimahadgi commented 2 years ago

I've tried a lot's different ways to install mysql2 gem on Windows Server 2019 and getting this error now: Ruby v 3 C:\Users\qauser>gem install mysql2 -- --with-mysql-dir="C:\Program Files\MariaDB\MariaDB Connector C 64-bit" ERROR: While executing gem ... (ArgumentError) undefined class/module YAML::Syck::

With ruby 2.7 I was able to install gem without this error.

rawlingsr commented 2 years ago

@dimahadgi I've tried on multiple machines, and I don't get that error.

I'm on ruby 3.1.2p20. gem -v gives 3.3.16. The connector version I downloaded was 3.1.17-GA. I'd try with those specific versions, as they seem to be the most up to date working combination. You can update rubygems using gem update --system

APonce911 commented 2 years ago

I had the same issue on Ubuntu 18.04.5, ruby 3.1.2, gem 3.3.7. Had to install libmysqlclient-dev.

For some reason, Ruby could not create the makefile for MySql since mkmf.rb#find_library was breaking on a nil value inside the paths array. I've monkey patched to compact this array, them I received the following message:

checking for -lmysqlclient... no

mysql client is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and try again.

After that I've installed libmysqlclient-dev and it worked on the next try.

betmenslido commented 2 years ago

I also encoutnered the same [i think] problem when building mysql2 from MSYS2 environment few days ago. I fixed it with following steps. Replace ucrt with x86_64 for your setup. 1) pacman -S mingw-w64-ucrt-x86_64-libmariadbclient 2) mkdir /tmp/mysql-lib-and-dll # we need to place dll+lib here; weirdly it seems that lib file is not used, but for some reason build fails without it. 3) touch /tmp/mysql-lib-and-dll/libmysql.lib # create blank file 4) cp /f/msys/ucrt64/bin/libmariadb.dll /tmp/mysql-lib-and-dll/libmysql.dll # mysql2 wants dll named libmysql 5) gem install mysql2 -- --with-mysql-lib="/tmp/mysql-lib-and-dll" --with-mysql-include="/f/msys/ucrt64/include/mariadb"

So I actually managed to build without mysql connector from mysql homepage, just using mingw build! I tried a few queries from rails and didnt notice any issues.