An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.

error information occurred when I execute "rails new demo1 -- database=mysql"

MY environment below: Mac OS 10.4.11, Ruby 1.8.7 Rails 3.2.1, Gem 1.8.15 mysql5 Ver 14.14 Distrib 5.1.61, for apple-darwin8.11.1 (i386) using readline 6.2 mysql (2.8.1)

Please help me, thx!

more detail message as follows:

Installing mysql2 (0.3.11) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /opt/local/bin/ruby extconf.rb checking for rb_thread_blocking_region()... no checking for rb_wait_for_single_fd()... no checking for mysql.h... yes checking for errmsg.h... yes checking for mysqld_error.h... yes creating Makefile

make /usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8 -I. - DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/opt/local/ include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -I/ opt/local/include/mysql5/mysql -fPIC -D_P1003_1B_VISIBLE - DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ - DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common - O2 -arch i386 -fno-common -pipe -fno-common -Wall -funroll-loops - arch i386 -c client.c /usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8 -I. - DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/opt/local/ include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -I/ opt/local/include/mysql5/mysql -fPIC -D_P1003_1B_VISIBLE - DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ - DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common - O2 -arch i386 -fno-common -pipe -fno-common -Wall -funroll-loops - arch i386 -c mysql2_ext.c ./client.h:20: warning: ‘rb_thread_blocking_region’ defined but not used /usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8 -I. - DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/opt/local/ include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -I/ opt/local/include/mysql5/mysql -fPIC -D_P1003_1B_VISIBLE - DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ - DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common - O2 -arch i386 -fno-common -pipe -fno-common -Wall -funroll-loops - arch i386 -c result.c /usr/bin/gcc-4.0 -dynamic -bundle -undefined suppress -flat_namespace - o mysql2.bundle client.o mysql2_ext.o result.o -L. -L/opt/local/lib -L/ opt/local/lib -L. -L/opt/local/lib -arch i386 -Wl,-rpath,/opt/local/ lib -arch i386 -lruby -L/opt/local/lib -L/opt/local/lib/mysql5/ mysql -lmysqlclient_r -L/opt/local/lib -lz -lm -L/opt/local/lib/ - lssl -lcrypto -lpthread -ldl -lobjc /usr/bin/ld: unknown flag: -rpath collect2: ld returned 1 exit status make: *** [mysql2.bundle] Error 1

Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/ mysql2-0.3.11 for inspection. Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.3.11/ext/ mysql2/gem_make.out An error occured while installing mysql2 (0.3.11), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

error information occurred when I execute "rails new demo1 -- database=mysql"

MY environment below: Mac OS 10.4.11, Ruby 1.8.7 Rails 3.2.1, Gem 1.8.15 mysql5 Ver 14.14 Distrib 5.1.61, for apple-darwin8.11.1 (i386) using readline 6.2 mysql (2.8.1)

Please help me, thx!

more detail message as follows:

Installing mysql2 (0.3.11) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

I am just answering as no one else has, I don't know about Macs so don't know the exact solution, but usually this sort of error is caused by some development tool or library that is not installed or is the wrong version. If you were following a set of instructions for installing on the Mac then maybe you have missed installing something. If you weren't then possibly you can find some to follow.

Colin

Hi Colin,

Thank your answer! I think you are right. I will recompile mysql with source package, and assign the directory of “lib,include,config” when the gem package installs.

Thank you again!

problem solve, type this command

sudo apt-get install libmysqlclient-dev

sudo apt-get install mysql

then run gem install mysql2