mysql2: `Installing mysql2 0.3.19 with native extensions` Hangs forever

on ruby 2.2.2 with rbenv 0.4.0 both on a Mac OS X 10.9.5 and Ubuntu 12.04 (fresh vagrant vm spun up with test-kitchen) bundle install (and gem install mysql2 -v 0.3.19) hangs forever installing the /opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/mysql2-0.3.19/ext/mysql2/mkmf.log just fills with a bunch of repeats of this


"gcc -o conftest -I/opt/rbenv/versions/2.2.2/include/ruby-2.2.0/x86_64-linux -I/opt/rbenv/versions/2.2.2/include/ruby-2.2.0/ruby/backward -I/opt/rbenv/versions/2.2.2/include/ruby-2.2.0 -I. -I/usr/local/include -I/opt/rbenv/versions/2.2.2/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c  -L/usr/local/lib -Wl,-R/usr/local/lib -L. -L/opt/rbenv/versions/2.2.2/lib -Wl,-R/opt/rbenv/versions/2.2.2/lib -L. -L/opt/rbenv/versions/2.2.2/lib  -fstack-protector -rdynamic -Wl,-export-dynamic    -lm  -Wl,-R/opt/rbenv/versions/2.2.2/lib -L/opt/rbenv/versions/2.2.2/lib -lruby-static -lmysqlclient -lm  -lpthread -lrt -ldl -lcrypt -lm   -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘mysql_query’ undeclared (first use in this function)
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:13:32: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     printf("%p", &t);
 9:   }
10:
11:   return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))mysql_query; return 0; }
/* end */

"gcc -o conftest -I/opt/rbenv/versions/2.2.2/include/ruby-2.2.0/x86_64-linux -I/opt/rbenv/versions/2.2.2/include/ruby-2.2.0/ruby/backward -I/opt/rbenv/versions/2.2.2/include/ruby-2.2.0 -I. -I/usr/local/include -I/opt/rbenv/versions/2.2.2/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c  -L/usr/local/lib -Wl,-R/usr/local/lib -L. -L/opt/rbenv/versions/2.2.2/lib -Wl,-R/opt/rbenv/versions/2.2.2/lib -L. -L/opt/rbenv/versions/2.2.2/lib  -fstack-protector -rdynamic -Wl,-export-dynamic    -lm  -Wl,-R/opt/rbenv/versions/2.2.2/lib -L/opt/rbenv/versions/2.2.2/lib -lruby-static -lmysqlclient -lm  -lpthread -lrt -ldl -lcrypt -lm   -lc"
conftest.c: In function ‘t’:
conftest.c:13:1: warning: implicit declaration of function ‘mysql_query’ [-Wimplicit-function-declaration]
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     printf("%p", &t);
 9:   }
10:
11:   return 0;
12: }
13: int t(void) { mysql_query(); return 0; }
/* end */

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 27

Most upvoted comments

just an FYI for future google searches, this hangs because of a loop that indefinitely tries to locate the mysql_config command. you can get past this by making sure that command is available, it usually is provided by the mysql-devel package for your distro.

For example yum install mysql-community-devel worked on CentOS 6 for me.

I had this happen to me as well, after i brew installed mysql, it was fixed.

@sodabrew, works for me: fails with error when libmysqlclient isn’t installed, succeeds when it is. Thanks!

Version 0.3.20 is now live, please make sure this problem is resolved for you all! Thanks again for reporting the issue!

Looks like it is stuck here https://github.com/brianmario/mysql2/blob/0.3.x/ext/mysql2/extconf.rb#L78

  while not find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql") do
    exit 1 if libs.empty?
    found ||= have_library(libs.shift)
  end

A fix for this is already in the master branch, looks like I neglected to backport it for the 0.3.19 release.

Please make sure that mysql_config or mariadb_config is available in your PATH or one of these default search paths to avoid the problem:

  /opt
  /opt/local
  /opt/local/mysql
  /opt/local/lib/mysql5*
  /usr
  /usr/mysql
  /usr/local
  /usr/local/mysql
  /usr/local/mysql-*
  /usr/local/lib/mysql5*