mysql2 icon indicating copy to clipboard operation
mysql2 copied to clipboard

Error Install mysql2 0.4.5 gem

Open klementtan opened this issue 5 years ago • 5 comments

Hi I have error installing mysql 0.4.5 gem.

I tried downloading opensll

Tried this solution https://github.com/brianmario/mysql2/issues/1005#issuecomment-424786695

but I still get this error message

gem install mysql2 -v '0.4.5' -- --with-mysql-config=/usr/local/Cellar/[email protected]/5.6.43/bin/mysql_config
Building native extensions with: '--with-mysql-config=/usr/local/Cellar/[email protected]/5.6.43/bin/mysql_config'
This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/var/rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
/usr/local/var/rbenv/versions/2.4.4/bin/ruby -r ./siteconf20190919-45649-1qutd9k.rb extconf.rb --with-mysql-config=/usr/local/Cellar/[email protected]/5.6.43/bin/mysql_config
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes
-----
Using mysql_config at /usr/local/Cellar/[email protected]/5.6.43/bin/mysql_config
-----
checking for mysql.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... no
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/[email protected]/5.6.43/lib
-----
creating Makefile

current directory: /usr/local/var/rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean

current directory: /usr/local/var/rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
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 /usr/local/var/rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5 for inspection.
Results logged to /usr/local/var/rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-18/2.4.0-static/mysql2-0.4.5/gem_make.out

Please help me thank you

klementtan avatar Sep 19 '19 12:09 klementtan

@klementtan Create if not exists: ~/.bundle/config and add BUNDLE_BUILD__MYSQL2: --with-opt-dir=/usr/local/opt/openssl.

lucasfeijo avatar Sep 27 '19 14:09 lucasfeijo

@klementtan Does this resolve your issue?

sodabrew avatar Oct 13 '19 00:10 sodabrew

@klementtan Create if not exists: ~/.bundle/config and add BUNDLE_BUILD__MYSQL2: --with-opt-dir=/usr/local/opt/openssl.

this way works for me

tetsundo avatar Nov 15 '19 08:11 tetsundo

BUNDLE_BUILD__MYSQL2: --with-opt-dir=/usr/local/opt/openssl

i'm with the same problem. I created the directory, but i dont know how to "ADD" BUNDLE_BUILD__MYSQL2: --with-opt-dir=/usr/local/opt/openssl. Please help me!

Rdlima83 avatar Jun 14 '20 23:06 Rdlima83

@Rdlima83 open your terminal and , command this$ vi ~/.bundle/config and add BUNDLE_BUILD__MYSQL2: --with-opt-dir=/usr/local/opt/openssl then save.

tetsundo avatar Jun 15 '20 00:06 tetsundo

run this command bundle config build.mysql2 --with-opt-dir=$(brew --prefix [email protected])

Yup, this solved the issue. Thank you!

klementtan avatar Sep 20 '22 16:09 klementtan