4

Installing Ruby/Rails/MySQL on a new MacBook Pro running OS High Sierra 10.13.6

I have Ruby version 2.1.4 installed via RVM (it's the version of Ruby used for this particular repo).

mysql is installed via brew:

mysql --version
mysql  Ver 8.0.12 for osx10.13 on x86_64 (Homebrew)

Then running bundle install and everything looks good except the process breaks when it tries to install the mysql2 gem:

Fetching mysql2 0.3.17
Installing mysql2 0.3.17 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/gregorybilello/.rvm/gems/ruby-2.1.4/gems/mysql2-0.3.17/ext/mysql2
/Users/gregorybilello/.rvm/rubies/ruby-2.1.4/bin/ruby -r
./siteconf20180926-52571-ppybdv.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting rpath to /usr/local/Cellar/mysql/8.0.12/lib
-----
creating Makefile

current directory:
/Users/gregorybilello/.rvm/gems/ruby-2.1.4/gems/mysql2-0.3.17/ext/mysql2
make "DESTDIR=" clean

current directory:
/Users/gregorybilello/.rvm/gems/ruby-2.1.4/gems/mysql2-0.3.17/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
client.c:359:33: warning: implicit conversion loses integer precision: 'long' to
'unsigned int' [-Wshorten-64-to-32]
        elapsed_time = end_time - start_time;
                     ~ ~~~~~~~~~^~~~~~~~~~~~
client.c:431:3: error: use of undeclared identifier 'my_bool'
  my_bool res = mysql_read_query_result(client);
  ^
client.c:433:19: error: use of undeclared identifier 'res'
  return (void *)(res == 0 ? Qtrue : Qfalse);
                  ^
client.c:762:3: error: use of undeclared identifier 'my_bool'
  my_bool boolval;
  ^
client.c:793:7: error: use of undeclared identifier 'boolval'
      boolval = (value == Qfalse ? 0 : 1);
      ^
client.c:794:17: error: use of undeclared identifier 'boolval'
      retval = &boolval;
                ^
client.c:797: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.12/include/mysql/mysql.h:188:3: note:
'MYSQL_DEFAULT_AUTH' declared here
  MYSQL_DEFAULT_AUTH,
  ^
client.c:798:7: error: use of undeclared identifier 'boolval'
      boolval = (value == Qfalse ? 0 : 1);
      ^
client.c:799:17: error: use of undeclared identifier 'boolval'
      retval = &boolval;
                ^
client.c:830:38: error: use of undeclared identifier 'boolval'
        wrapper->reconnect_enabled = boolval;
                                     ^
client.c:1163:56: warning: implicit conversion loses integer precision: 'size_t'
(aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
  mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len);
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~               ^~~~~~~~~~~~~~~~
client.c:1196: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.12/include/mysql/mysql.h:188:3: note:
'MYSQL_DEFAULT_AUTH' declared here
  MYSQL_DEFAULT_AUTH,
  ^
2 warnings and 10 errors generated.
make: *** [client.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/gregorybilello/.rvm/gems/ruby-2.1.4/gems/mysql2-0.3.17 for inspection.
Results logged to
/Users/gregorybilello/.rvm/gems/ruby-2.1.4/extensions/x86_64-darwin-17/2.1.0/mysql2-0.3.17/gem_make.out

An error occurred while installing mysql2 (0.3.17), and Bundler cannot
continue.
Make sure that `gem install mysql2 -v '0.3.17' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  mysql2
gregorybilello@Gregorys-MBP-2 portal (production) $ mysql --version
mysql  Ver 8.0.12 for osx10.13 on x86_64 (Homebrew)
gregorybilello@Gregorys-MBP-2 portal (production) $ gem install mysql2 -v '0.3.17' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
Building native extensions with: '--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include'
This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    current directory: /Users/gregorybilello/.rvm/gems/ruby-2.1.4/gems/mysql2-0.3.17/ext/mysql2
/Users/gregorybilello/.rvm/rubies/ruby-2.1.4/bin/ruby -r ./siteconf20180926-53492-1uypkd1.rb extconf.rb --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting rpath to /usr/local/Cellar/mysql/8.0.12/lib
-----
creating Makefile

current directory: /Users/gregorybilello/.rvm/gems/ruby-2.1.4/gems/mysql2-0.3.17/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/gregorybilello/.rvm/gems/ruby-2.1.4/gems/mysql2-0.3.17/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
client.c:359:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
        elapsed_time = end_time - start_time;
                     ~ ~~~~~~~~~^~~~~~~~~~~~
client.c:431:3: error: use of undeclared identifier 'my_bool'
  my_bool res = mysql_read_query_result(client);
  ^
client.c:433:19: error: use of undeclared identifier 'res'
  return (void *)(res == 0 ? Qtrue : Qfalse);
                  ^
client.c:762:3: error: use of undeclared identifier 'my_bool'
  my_bool boolval;
  ^
client.c:793:7: error: use of undeclared identifier 'boolval'
      boolval = (value == Qfalse ? 0 : 1);
      ^
client.c:794:17: error: use of undeclared identifier 'boolval'
      retval = &boolval;
                ^
client.c:797: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.12/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here
  MYSQL_DEFAULT_AUTH,
  ^
client.c:798:7: error: use of undeclared identifier 'boolval'
      boolval = (value == Qfalse ? 0 : 1);
      ^
client.c:799:17: error: use of undeclared identifier 'boolval'
      retval = &boolval;
                ^
client.c:830:38: error: use of undeclared identifier 'boolval'
        wrapper->reconnect_enabled = boolval;
                                     ^
client.c:1163:56: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
  mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len);
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~               ^~~~~~~~~~~~~~~~
client.c:1196: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.12/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here
  MYSQL_DEFAULT_AUTH,
  ^
2 warnings and 10 errors generated.
make: *** [client.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/gregorybilello/.rvm/gems/ruby-2.1.4/gems/mysql2-0.3.17 for inspection.
Results logged to /Users/gregorybilello/.rvm/gems/ruby-2.1.4/extensions/x86_64-darwin-17/2.1.0/mysql2-0.3.17/gem_make.out

I'm sure I've done something wrong with the install, but any ideas of how to get this working? Thanks.

  • Can you try with this link: [https://stackoverflow.com/questions/11881785/gem-install-mysql-failed-to-build-gem-native-extension-mac-lion](https://stackoverflow.com/questions/11881785/gem-install-mysql-failed-to-build-gem-native-extension-mac-lion) – tekuri Sep 27 '18 at 02:01
  • Given that you use MySQL 8 (latest) but try to install mysql2 gem with v0.3.17 I assume it’s just not compatible seeing the compiler error. The latest version of that gem is v0.5.2. Can you try installing/upgrading to that? – ur5us Sep 27 '18 at 02:14
  • 1
    Like others have mentioned, you should move on to a newer version of `mysql2`, they seem to have resolved these issues in version `0.4.10` – Kedarnag Mukanahallipatna Sep 27 '18 at 02:33
  • try running `gem install mysql2 -v '0.3.17' --source 'https://rubygems.org/'` and then `bundle install`. – Arihant Sep 27 '18 at 03:26
  • did you tried to run one more time 'brew install mysql' – Nezir Sep 27 '18 at 16:13
  • also here is some solution https://stackoverflow.com/questions/50909928/installing-mysql-2-gem-fails – Nezir Sep 27 '18 at 16:15
  • 3
    Thanks, everyone. Turns out the MySQL installed version was indeed not compatible with the version of the mysql2 gem being used by the repo. I uninstalled MySQL 8 and then installed MySQL 5.7 and everything worked just fine. – galactic_annihilator Sep 28 '18 at 13:30

0 Answers0