Posts mit dem Label gem werden angezeigt. Alle Posts anzeigen
Posts mit dem Label gem werden angezeigt. Alle Posts anzeigen

Mittwoch, 3. September 2014

MacPorts and installing Ruby's mysql gem

MySQL 5.5 client and server is installed using MacPorts. When trying to install the mysql2-gem, it will fail as follows:
 $ sudo gem install mysql2 -v '0.3.16'
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
 ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby 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
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
It seems like it has trouble locating the mysqlclient. A quick search in /opt discovered /opt/local/lib/mysql55/bin/mysql_config. mysql_config will help gem to find the mysql libraries:
 $ sudo gem install mysql2 -v '0.3.16' -- --with-mysql-config=/opt/local/lib/mysql55/bin/mysql_config
Building native extensions with: '--with-mysql-config=/opt/local/lib/mysql55/bin/mysql_config'
This could take a while...
Successfully installed mysql2-0.3.16
Parsing documentation for mysql2-0.3.16
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for lib/mysql2/mysql2.bundle, skipping
Installing ri documentation for mysql2-0.3.16
1 gem installed
Voila.