対象環境
- CentOS 6.7
- Ruby2.1
- Rails4.1
- MySQL Community Server 5.6.26
概要
Redmineをインストールするにあたって、MySQLをインストールし、Railsで使用するライブラリmysql2のインストールでエラーとなる。
$ gem install mysql2 -v '0.3.19' Fetching: mysql2-0.3.19.gem (100%) Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /usr/local/ruby2.2/bin/ruby -r ./siteconf20150814-32250-1l3iwxf.rb 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()... no checking for rb_wait_for_single_fd()... yes checking for rb_hash_dup()... yes checking for rb_intern3()... yes ----- Using mysql_config at /usr/bin/mysql_config ----- checking for mysql.h... no checking for mysql/mysql.h... no ----- mysql.h is missing. Try 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', check your installation of mysql and try again. ----- *** 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. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/ruby2.2/bin/$(RUBY_BASE_NAME) --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysql-config --without-mysql-config extconf failed, exit code 1
Windows環境でハマった時の対応方法は、この記事であるが、今回の環境はまた異なるし、対応方法が異なるようだ。
そこで下記`mysql-devel`をインストール。
$ yum install mysql-devel 読み込んだプラグイン:fastestmirror, security インストール処理の設定をしています Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: centos.usonyx.net パッケージ mysql-devel は mysql-community-devel によって不要になりました。代わりに mysql-community-devel-5.6.26-2.el6.x86_64 のインストールを試みています。 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> Package mysql-community-devel.x86_64 0:5.6.26-2.el6 will be インストール --> 依存性解決を終了しました。 依存性を解決しました ==================================================================================================== パッケージ アーキテクチャ バージョン リポジトリー 容量 ==================================================================================================== インストールしています: mysql-community-devel x86_64 5.6.26-2.el6 mysql56-community 3.2 M トランザクションの要約 ==================================================================================================== インストール 1 パッケージ 総ダウンロード容量: 3.2 M インストール済み容量: 20 M これでいいですか? [y/N]y パッケージをダウンロードしています: mysql-community-devel-5.6.26-2.el6.x86_64.rpm | 3.2 MB 00:01 rpm_check_debug を実行しています トランザクションのテストを実行しています トランザクションのテストを成功しました トランザクションを実行しています インストールしています : mysql-community-devel-5.6.26-2.el6.x86_64 1/1 Verifying : mysql-community-devel-5.6.26-2.el6.x86_64 1/1 インストール: mysql-community-devel.x86_64 0:5.6.26-2.el6 完了しました!
再度、試したら上手く行った。
$ gem install mysql2 Building native extensions. This could take a while... Successfully installed mysql2-0.3.19 Parsing documentation for mysql2-0.3.19 Installing ri documentation for mysql2-0.3.19 Done installing documentation for mysql2 after 1 seconds 1 gem installed