Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error installing mysql2 on Mac M1 pro (ventura) #1335

Open
VictorOnwukwe opened this issue Oct 17, 2023 · 4 comments
Open

Error installing mysql2 on Mac M1 pro (ventura) #1335

VictorOnwukwe opened this issue Oct 17, 2023 · 4 comments

Comments

@VictorOnwukwe
Copy link

VictorOnwukwe commented Oct 17, 2023

Hello. I am trying to install mysql2 on my macOS M1 pro (ventura 13.3.1) using the below command:

gem install mysql2 -v '0.5.5' -- --with-mysql-config=$(brew --prefix mysql)/bin/mysql_config --with-ldflags="-L$(brew --prefix zstd)/lib -L$(brew --prefix openssl)/lib" --with-cppflags=-I$(brew --prefix openssl)/include

as suggested here

I am getting the below error

Building native extensions with: '--with-mysql-config=/opt/homebrew/opt/mysql/bin/mysql_config --with-ldflags=-L/opt/homebrew/opt/zstd/lib -L/opt/homebrew/opt/openssl@3/lib --with-cppflags=-I/opt/homebrew/opt/openssl@3/include'
This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

    current directory: /Users/victoronwukwe/.rvm/gems/ruby-3.2.2/gems/mysql2-0.5.5/ext/mysql2
/Users/victoronwukwe/.rvm/rubies/ruby-3.2.2/bin/ruby extconf.rb --with-mysql-config\=/opt/homebrew/opt/mysql/bin/mysql_config --with-ldflags\=-L/opt/homebrew/opt/zstd/lib\ -L/opt/homebrew/opt/openssl@3/lib --with-cppflags\=-I/opt/homebrew/opt/openssl@3/include
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
-----
Cannot find library dir(s) /usr/share/rvm/usr/lib
-----
*** 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=/Users/victoronwukwe/.rvm/rubies/ruby-3.2.2/bin/$(RUBY_BASE_NAME)
	--with-openssl-dir
	--with-openssl-dir
	--with-openssl-include
	--without-openssl-include=${openssl-dir}/include
	--with-openssl-lib
	--without-openssl-lib=${openssl-dir}/lib

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

  /Users/victoronwukwe/.rvm/gems/ruby-3.2.2/extensions/arm64-darwin-22/3.2.0/mysql2-0.5.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/victoronwukwe/.rvm/gems/ruby-3.2.2/gems/mysql2-0.5.5 for inspection.
Results logged to /Users/victoronwukwe/.rvm/gems/ruby-3.2.2/extensions/arm64-darwin-22/3.2.0/mysql2-0.5.5/gem_make.out

Any suggestion will be appreciated. I'll be happy to provide any further required information.

@VictorOnwukwe
Copy link
Author

After trying just about every proposed solution by both humans and AI, I eventually resolved this issue by uninstalling ruby and rvm completely and then reinstalling. I still don't know what caused the issue. But this was my fix. Just leaving this out here.

@sreenak
Copy link

sreenak commented Feb 8, 2024

@VictorOnwukwe Could you please share here which tutorial you followed to install all, even I have the same issue, struggling with it.

@VictorOnwukwe
Copy link
Author

@sreenak I can't recall the tutorial I followed, but I stored the command that worked. Here it is:

gem install mysql2 -v ‘0.5.5’ -- --with-ldflags=-L/opt/homebrew/opt/openssl@3/lib --with-cppflags=-I/opt/homebrew/opt/openssl@3/include

@trevorh
Copy link

trevorh commented Apr 14, 2024

Just in case the other commands don't work. This is what worked for me.

  • MacOS Sonoma (14.2.1) - M1 Max w/ zsh & rbenv
  • ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin23]
gem uninstall mysql2

bundle config --local build.mysql2 -- --with-mysql-config=$(brew --prefix mysql)/bin/mysql_config --with-ldflags="-L$(brew --prefix zstd)/lib -L$(brew --prefix openssl)/lib" --with-cppflags=-I$(brew --prefix openssl)/include --with-cflags="-Wno-error=implicit-function-declaration"

bundle install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants