Skip to content

Instantly share code, notes, and snippets.

@simonqian
Created June 1, 2017 07:19
Show Gist options
  • Select an option

  • Save simonqian/ab3e26c00a0ed04758ac3e96334cf18f to your computer and use it in GitHub Desktop.

Select an option

Save simonqian/ab3e26c00a0ed04758ac3e96334cf18f to your computer and use it in GitHub Desktop.

error info:

➜  hh (hh_api) ✗ gem install mysql2
Fetching: mysql2-0.4.6.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

    current directory: /Users/simonqian/.rvm/gems/ruby-2.2.2@rails4/gems/mysql2-0.4.6/ext/mysql2
/Users/simonqian/.rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20170601-29418-1uit6cw.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... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting rpath to /usr/local/Cellar/mariadb/10.2.6/lib
-----
creating Makefile

current directory: /Users/simonqian/.rvm/gems/ruby-2.2.2@rails4/gems/mysql2-0.4.6/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/simonqian/.rvm/gems/ruby-2.2.2@rails4/gems/mysql2-0.4.6/ext/mysql2
make "DESTDIR="
compiling client.c
client.c:138:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
client.c:923:32: error: use of undeclared identifier 'MYSQL_SERVER_VERSION'
  header_version = rb_str_new2(MYSQL_LINK_VERSION);
                               ^
client.c:53:30: note: expanded from macro 'MYSQL_LINK_VERSION'
  #define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
                             ^
client.c:923:32: error: use of undeclared identifier 'MYSQL_SERVER_VERSION'
client.c:53:30: note: expanded from macro 'MYSQL_LINK_VERSION'
  #define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
                             ^
client.c:923:32: error: use of undeclared identifier 'MYSQL_SERVER_VERSION'
client.c:53:30: note: expanded from macro 'MYSQL_LINK_VERSION'
  #define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
                             ^
client.c:923:32: error: use of undeclared identifier 'MYSQL_SERVER_VERSION'
client.c:53:30: note: expanded from macro 'MYSQL_LINK_VERSION'
  #define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
                             ^
client.c:923:18: error: assigning to 'VALUE' (aka 'unsigned long') from incompatible type 'void'
  header_version = rb_str_new2(MYSQL_LINK_VERSION);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 5 errors generated.
make: *** [client.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/simonqian/.rvm/gems/ruby-2.2.2@rails4/gems/mysql2-0.4.6 for inspection.
Results logged to /Users/simonqian/.rvm/gems/ruby-2.2.2@rails4/extensions/x86_64-darwin-16/2.2.0/mysql2-0.4.6/gem_make.out

my mariadb info:

➜  ~ brew info mariadb
mariadb: stable 10.2.6 (bottled)
Drop-in replacement for MySQL
https://mariadb.org/
Conflicts with: mariadb-connector-c, mysql, mysql-cluster, mysql-connector-c, mytop, percona-server
/usr/local/Cellar/mariadb/10.0.19 (537 files, 130.2MB)
  Poured from bottle on 2015-05-09 at 15:36:52
/usr/local/Cellar/mariadb/10.2.6 (620 files, 145.0MB) *
  Poured from bottle on 2017-05-31 at 14:10:10
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mariadb.rb
==> Dependencies
Build: cmake ✔
Required: openssl ✔
==> Options
--with-archive-storage-engine
	Compile with the ARCHIVE storage engine enabled
--with-bench
	Keep benchmark app when installing
--with-blackhole-storage-engine
	Compile with the BLACKHOLE storage engine enabled
--with-embedded
	Build the embedded server
--with-libedit
	Compile with editline wrapper instead of readline
--with-local-infile
	Build with local infile loading support
--with-test
	Keep test when installing
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

MySQL is configured to only allow connections from localhost by default

To connect:
    mysql -uroot

To have launchd start mariadb now and restart at login:
  brew services start mariadb
Or, if you don't want/need a background service you can just run:
  mysql.server start

my mariadb version is too height, switch to 10.0.19 and resolve this problem:

➜  ~ brew switch mariadb 10.0.19
Cleaning /usr/local/Cellar/mariadb/10.0.19
Cleaning /usr/local/Cellar/mariadb/10.2.6
109 links created for /usr/local/Cellar/mariadb/10.0.19

and then:

➜  hh (hh_api) ✗ gem install mysql2
Building native extensions.  This could take a while...
Successfully installed mysql2-0.4.6
Parsing documentation for mysql2-0.4.6
Installing ri documentation for mysql2-0.4.6
Done installing documentation for mysql2 after 0 seconds
1 gem installed

then, bundle install:

➜  hh (hh_api) ✗ bundle
...
...
Bundle complete! 62 Gemfile dependencies, 160 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment