Error Installing Mysql2

Hi,

Could someone help me, I am trying to install on macOSx but getting stuck with mysql2 install.

    iJamies-MacBook-Pro:sharetribe hookj03$ bundle install
Fetching gem metadata from http://rubygems.org/.............
Fetching version metadata from http://rubygems.org/...
Fetching dependency metadata from http://rubygems.org/..
Resolving dependencies...
Using rake 11.3.0
Using concurrent-ruby 1.0.5
Using i18n 0.8.4
Using minitest 5.10.2
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubi 1.6.0
Using mini_portile2 2.1.0
Using rack 2.0.3
Using nio4r 2.1.0
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 8.0.0
Using multi_json 1.12.1
Using method_source 0.8.2
Using thor 0.19.4
Using addressable 2.3.8
Using airbrake-ruby 2.2.6
Using ast 2.3.0
Using awesome_print 1.7.0
Using aws-sigv4 1.0.0
Using jmespath 1.3.1
Using bcrypt 3.1.11
Using coderay 1.1.1
Using erubis 2.7.0
Using bindex 0.5.0
Using debug_inspector 0.0.3
Using bundler 1.15.3
Using byebug 9.0.6
Using callsite 0.0.11
Using ffi 1.9.18
Using chunky_png 1.3.8
Using climate_control 0.2.0
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using color 1.8
Using sass 3.4.24
Using rb-fsevent 0.9.8
Using tilt 2.0.7
Using connection_pool 2.2.1
Using i18n_data 0.7.0
Using sixarm_ruby_unaccent 1.1.1
Using unicode_utils 1.4.0
Using gherkin 4.1.3
Using cucumber-wire 0.0.1
Using diff-lcs 1.3
Using multi_test 0.1.2
Using dalli 2.7.6
Using database_cleaner 1.6.1
Using mimemagic 0.3.2
Using orm_adapter 0.5.0
Using unf_ext 0.0.7.4
Using dynamic_form 1.1.4
Using htmlentities 4.3.4
Using multipart-post 2.0.0
Using json 2.1.0
Using websocket 1.2.4
Using riddle 2.1.0
Using innertube 1.1.0
Using middleware 0.1.0
Using formatador 0.2.5
Using ruby_dep 1.5.0
Using lumberjack 1.0.12
Using nenv 0.3.0
Using shellany 0.0.1
Using slop 3.6.0
Using guard-compat 1.2.1
Using rspec-support 3.6.0
Using temple 0.8.0
Using hashie 3.5.5
Using hiredis 0.6.1
Using jwt 1.5.6
Using libv8 3.16.14.19 (x86_64-darwin-16)
Using memcachier 0.0.2
Using msgpack 1.1.0
Using multi_xml 0.6.0
Fetching mysql2 0.4.6
Installing mysql2 0.4.6 with native extensions
Using netrc 0.11.0
Using newrelic_rpm 4.2.0.334
Using oj 2.18.5
Using parallel 1.11.2
Using xml-simple 1.1.5
Using possibly 1.0.1
Using powerpack 0.1.1
Using public_suffix 2.0.5
Using rails_serve_static_assets 0.0.5
Using rails_stdout_logging 0.0.5
Using redis 3.3.3
Using redcarpet 3.4.0
Using ref 2.0.0
Using request_store 1.3.2
Using ruby-progressbar 1.8.1
Using unicode-display_width 1.2.1
Using rubyzip 1.2.1
Using statesman 2.0.1
Using stringex 2.7.1
Using timecop 0.8.1
Using trollop 2.1.2
Using truncate_html 0.9.3
Using uuidtools 2.1.5
Using will_paginate 3.1.5
Using rainbow 2.2.2
Using i18n-js 3.0.0
Using tzinfo 1.2.3
Using sitemap_generator 5.3.1
Fetching nokogiri 1.7.2
Installing nokogiri 1.7.2 with native extensions
Using rack-test 0.6.3
Using sprockets 3.7.1
Using warden 1.2.7
Using rack-contrib 1.2.0
Using passenger 5.1.4
Using websocket-driver 0.6.5
Using mime-types 3.1
Using zeus 0.15.13
Using css_parser 1.5.0
Using launchy 2.4.3
Using airbrake 6.1.2
Using parser 2.4.0.0
Using aws-sdk-core 2.9.25
Using better_errors 2.1.1
Using binding_of_caller 0.7.2
Using childprocess 0.7.0
Using rb-inotify 0.9.8
Using cocaine 0.5.8
Using coffee-script 2.4.1
Using uglifier 3.2.0
Using compass-core 1.0.3
Using compass-import-once 1.0.5
Using mail_view 2.0.4
Using money 6.8.4
Using cucumber-core 1.5.0
Using unf 0.1.4
Using faraday 0.11.0
Using intercom 3.5.14
Using pusher-client 0.6.2
Using notiffany 0.1.1
Using pry 0.10.4
Using rspec-core 3.6.0
Using rspec-expectations 3.6.0
Using rspec-mocks 3.6.0
Using haml 5.0.1
Using omniauth 1.6.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/hookj03/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2
/Users/hookj03/.rbenv/versions/2.3.3/bin/ruby -r ./siteconf20170811-69831-1jc7ld.rb
extconf.rb
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/bin/mysql_config
-----
checking for mysql.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 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/mysql/5.7.19/lib
-----
creating Makefile

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

/Users/hookj03/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.6/mkmf.log

current directory:
/Users/hookj03/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2
make "DESTDIR=" clean

current directory:
/Users/hookj03/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
result.c:326:40: warning: incompatible pointer types assigning to 'my_bool *' (aka 'char
*') from 'bool *' [-Wincompatible-pointer-types]
    wrapper->result_buffers[i].is_null = &wrapper->is_null[i];
                                       ^ ~~~~~~~~~~~~~~~~~~~~
result.c:328:40: warning: incompatible pointer types assigning to 'my_bool *' (aka 'char
*') from 'bool *' [-Wincompatible-pointer-types]
    wrapper->result_buffers[i].error   = &wrapper->error[i];
                                       ^ ~~~~~~~~~~~~~~~~~~
2 warnings generated.
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
/Users/hookj03/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6 for inspection.
Results logged to
/Users/hookj03/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.6/gem_make.out

An error occurred while installing mysql2 (0.4.6), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.6'` succeeds before bundling.

In Gemfile:
  mysql2
Jamies-MacBook-Pro:sharetribe hookj03$

I resolved this by installing Xcode and running

code-select --install\

then
gem install mysql2

1 Like

Great to hear that it works now, Jamie!

And thanks a lot for sharing your solution :bow:
This will surely help other people who may face a similar issue.

Keep up the good work!

Hi Jamie, is sharetribe working as expected on Mac?

Thank you
Riani

hello! im having the same issue, and Xcode says command not found.

it says this:
client.c:869:10: error: use of undeclared identifier ‘MYSQL_SECURE_AUTH’; did you mean
‘MYSQL_DEFAULT_AUTH’?
case MYSQL_SECURE_AUTH:
^~~~~~~~~~~~~~~~~
MYSQL_DEFAULT_AUTH
/usr/local/Cellar/mysql/8.0.11/include/mysql/mysql.h:188:3: note: ‘MYSQL_DEFAULT_AUTH’
declared here
MYSQL_DEFAULT_AUTH,
^
client.c:1291:38: error: use of undeclared identifier ‘MYSQL_SECURE_AUTH’; did you mean
‘MYSQL_DEFAULT_AUTH’?
return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
^~~~~~~~~~~~~~~~~
MYSQL_DEFAULT_AUTH
/usr/local/Cellar/mysql/8.0.11/include/mysql/mysql.h:188:3: note: ‘MYSQL_DEFAULT_AUTH’
declared here
MYSQL_DEFAULT_AUTH,
^
2 errors generated.
make: *** [client.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/jorgeruiz/.rvm/gems/ruby-2.3.4/gems/mysql2-0.4.6 for inspection.
Results logged to
/Users/jorgeruiz/.rvm/gems/ruby-2.3.4/extensions/x86_64-darwin-16/2.3.0/mysql2-0.4.6/gem_make.out

can anyone help me?

made it work changing the gemfile

gem mysql2 (0.4.6) to gem (0.5.2)

Thanks Jorge, this works for me too!

Worked for me too! Thanks Jorge