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 v0.5.5 on Rails app with ruby 3.3.0 on macOS Sonoma v14.2 M2 chipset #1342

Open arthurduarte1 opened 8 months ago

arthurduarte1 commented 8 months ago

Any ideas on how to solve it? Thanks in advanced.

bundle install
Fetching gem metadata from https://rubygems.org/........
Installing mysql2 0.5.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: ~/.rvm/gems/ruby-3.3.0/gems/mysql2-0.5.5/ext/mysql2
~/.rvm/rubies/ruby-3.3.0/bin/ruby extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_gc_mark_movable()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enc_interned_str() in ruby.h... yes
-----
Using --with-openssl-dir=/opt/homebrew/opt/openssl@3
-----
-----
Using mysql_config at /opt/homebrew/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes
checking for MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_DEFAULT_AUTH in mysql.h... yes
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.h... no
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may
not load
-----
-----
Setting libpath to /opt/homebrew/Cellar/mysql/8.2.0_1/lib
-----
creating Makefile

current directory: ~/.rvm/gems/ruby-3.3.0/gems/mysql2-0.5.5/ext/mysql2
make DESTDIR\= sitearchdir\=./.gem.20240108-35620-rh00vh
sitelibdir\=./.gem.20240108-35620-rh00vh clean

current directory: ~/.rvm/gems/ruby-3.3.0/gems/mysql2-0.5.5/ext/mysql2
make DESTDIR\= sitearchdir\=./.gem.20240108-35620-rh00vh
sitelibdir\=./.gem.20240108-35620-rh00vh
compiling client.c
In file included from client.c:15:
./mysql_enc_name_to_ruby.h:43:1: warning: a function definition without a prototype is
deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
mysql2_mysql_enc_name_to_rb_hash (str, len)
^
./mysql_enc_name_to_ruby.h:86:1: warning: a function definition without a prototype is
deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
mysql2_mysql_enc_name_to_rb (str, len)
^
2 warnings generated.
compiling infile.c
compiling mysql2_ext.c
compiling result.c
result.c:304:35: warning: implicit conversion loses integer precision: 'unsigned long' to
'int' [-Wshorten-64-to-32]
        precision = field->length - (field->decimals > 0 ? 2 : 1);
                  ~ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library 'zstd' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in ~/.rvm/gems/ruby-3.3.0/gems/mysql2-0.5.5 for
inspection.
Results logged to
~/.rvm/gems/ruby-3.3.0/extensions/arm64-darwin-23/3.3.0/mysql2-0.5.5/gem_make.out

  ~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/builder.rb:125:in `run'
~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/builder.rb:51:in `block in
make'
  ~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/builder.rb:43:in `each'
  ~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/builder.rb:43:in `make'
~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/ext_conf_builder.rb:42:in
`build'
~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/builder.rb:193:in
`build_extension'
~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/builder.rb:227:in `block in
build_extensions'
  ~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `each'
~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in
`build_extensions'
~/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/installer.rb:852:in
`build_extensions'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/rubygems_gem_installer.rb:76:in
`build_extensions'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/source/rubygems.rb:205:in
`install'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/installer/gem_installer.rb:54:in
`install'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/installer/parallel_installer.rb:132:in
`do_install'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/installer/parallel_installer.rb:123:in
`block in worker_pool'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/worker.rb:62:in
`apply_func'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/worker.rb:57:in `block in
process_queue'
  <internal:kernel>:187:in `loop'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/worker.rb:54:in
`process_queue'
~/.rvm/gems/ruby-3.3.0/gems/bundler-2.5.4/lib/bundler/worker.rb:90:in `block (2
levels) in create_threads'

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

In Gemfile:
  mysql2

RVM Version:

rvm --version
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

Ruby version:

ruby --version
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
nelseric commented 8 months ago

I tried installing the gem with gem install mysql2 -- --with-ldflags=-L$(brew --prefix zstd)/lib and it seemed to fix the problem locally.

liunian-zy commented 7 months ago

I tried installing the gem with gem install mysql2 -- --with-ldflags=-L$(brew --prefix zstd)/lib and it seemed to fix the problem locally.

tks bro!

kaushiklad55 commented 7 months ago

work

yzgan commented 6 months ago

I tried installing the gem with gem install mysql2 -- --with-ldflags=-L$(brew --prefix zstd)/lib and it seemed to fix the problem locally.

Thanks. It resolved my issue with ruby 3.3.0 and mac M1 machine.

samholst commented 4 months ago

Thanks!

kartiktailwebs commented 4 months ago

I tried installing the gem with gem install mysql2 -- --with-ldflags=-L$(brew --prefix zstd)/lib and it seemed to fix the problem locally.

Yes, using this command it's working on my mac m2 chip. Thanks @nelseric

RulerOf commented 3 months ago

I used this just to make sure it was linked to the right OpenSSL version as well:

bundle config --local build.mysql2 -- --with-ldflags=-L$(brew --prefix zstd)/lib $(ruby -r rbconfig -e 'puts RbConfig::CONFIG["configure_args"]' | xargs -n1 | grep with-openssl-dir)
fabiensebban commented 2 months ago

I tried installing the gem with gem install mysql2 -- --with-ldflags=-L$(brew --prefix zstd)/lib and it seemed to fix the problem locally.

Work for me on Sonoma 14.5 M1 Pro chip. Thanks @nelseric!

JuanVqz commented 1 month ago

I tried installing the gem with gem install mysql2 -- --with-ldflags=-L$(brew --prefix zstd)/lib and it seemed to fix the problem locally.

This worked for me with the following specs:

Mac M3 Sonoma 14.6.1 Ruby 3.0.7 Mysql gem v0.5.6