gem install mysql2 でエラー on Mac

2011年11月23日 Posted by PURGE

gem install mysql2 でエラーが発生し、どうしてもインストールできない。エラーはどうやらインストールされている mysql のヘッダ等が読み込めないとのことなので、gem install オプションを付けた。
しかし、どうしてもうまくいかない。

$ gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib/ --with-mysqlclientlib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include/
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

        /Users/username/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib/ --with-mysqlclientlib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include/
checking for rb_thread_blocking_region()... yes
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.2 -I. -I/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin10.8.0 -I/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -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 i386 -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe -Wall -funroll-loops  -o client.o -c client.c
In file included from /Users/northvan/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby.h:32,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/ruby.h:108: error: size of array ‘ruby_check_sizeof_long’ is negative
/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/ruby.h:112: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/intern.h:29,
                 from /Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/ruby.h:1327,
                 from /Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby.h:32,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/st.h:69: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
make: *** [client.o] Error 1


Gem files will remain installed in /Users/username/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.10 for inspection.
Results logged to /Users/username/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.10/ext/mysql2/gem_make.out

で3日はまったところで、下記の記事を発見。

http://www.mountposition.co.jp/blog/?p=210

mysql 32bit版から、64bit版へ再インストール。

gem install mysql2 が動きました。

$ gem install mysql2
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.10
1 gem installed
Installing ri documentation for mysql2-0.3.10...
Installing RDoc documentation for mysql2-0.3.10...

でも、32bit版PCで、64bit版のmysqlが動くのかいな?という感じです。狐につままれた感じ。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です