Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.5
-
Fix Version/s: JRuby 1.6.6, JRuby 1.7.0.pre1
-
Component/s: C Extensions
-
Labels:None
-
Environment:Hidematt@foo:~/Projects/personal $ uname -a
Darwin foo 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
matt@foo:~/Projects/personal $ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
matt@foo:~/Projects/personal $ jruby --version
jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [darwin-x86_64-java]Showmatt@foo :~/Projects/personal $ uname -a Darwin foo 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64 matt@foo :~/Projects/personal $ gcc --version i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. matt@foo :~/Projects/personal $ jruby --version jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [darwin-x86_64-java]
-
Number of attachments :
Description
I installed JRuby 1.6.5 using rvm and then tried to do 'gem install mysql2'. Unfortunately as I'm running an up-to-date XCode the native extension cannot be built because of '-rpath' being used. The full output is included after this description.
The problem is due to '-mmacos-version-min=10.4' being set in the JRuby source code. I've forked the git repo and submitted a pull request (https://github.com/jruby/jruby/pull/98) that simply updates the value of this to 10.5. I have compiled JRuby using this change and managed to install the mysql2 gem with it. It might not be the ideal solution but it certainly solves this problem.
The full error from 'gem install mysql2':
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/matt/.rvm/rubies/jruby-1.6.5/bin/jruby extconf.rb
WARNING: JRuby does not support native extensions or the `mkmf' library very well.
Check http://kenai.com/projects/jruby/pages/Home for alternatives.
checking for rb_thread_blocking_region()... 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
cc -I. -I. -I/Users/matt/.rvm/rubies/jruby-1.6.5/lib/native/include/ruby -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64 -fPIC -DTARGET_RT_MAC_CFM=0 -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions -Wall -funroll-loops -arch x86_64 -c client.c
cc -I. -I. -I/Users/matt/.rvm/rubies/jruby-1.6.5/lib/native/include/ruby -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64 -fPIC -DTARGET_RT_MAC_CFM=0 -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions -Wall -funroll-loops -arch x86_64 -c mysql2_ext.c
cc -I. -I. -I/Users/matt/.rvm/rubies/jruby-1.6.5/lib/native/include/ruby -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64 -fPIC -DTARGET_RT_MAC_CFM=0 -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions -Wall -funroll-loops -arch x86_64 -c result.c
cc -dynamic -bundle -undefined dynamic_lookup -o mysql2.bundle client.o mysql2_ext.o result.o -L"." -L"/Users/matt/.rvm/rubies/jruby-1.6.5/lib" -bundle -framework JavaVM -Wl,-syslibroot, -mmacosx-version-min=10.4 -Wl,-rpath,/usr/local/mysql/lib -arch x86_64 -L/usr/local/mysql/lib -lmysqlclient_r -lpthread
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: ld returned 1 exit status
make: *** [mysql2.bundle] Error 1
Gem files will remain installed in /Users/matt/.rvm/gems/jruby-1.6.5/gems/mysql2-0.3.8 for inspection.
Results logged to /Users/matt/.rvm/gems/jruby-1.6.5/gems/mysql2-0.3.8/ext/mysql2/gem_make.out
For one thing, you shouldn't use mysql2 gem. If you need database connections, you should try jdbc-mysql. (And if you need it for ActiveRecord, activerecord-jdbcmysql-adapter.)
For another, it might be better to have a more general solution, where these flags can be overridden. Namely, we should perhaps look at environment variables instead of hardcoding them.