長くてややこしいタイトルですが・・・
・ローカル環境下でRedmineを使いたい。
・DBはXAMPPに付属のMySQLを使いたい。
・なお、Homebrewを利用している。
というところから始まり
MySQL2をインストールする際に、コンパイルが通らなかったりして苦労した話。
各種ソフトウェアの手順書は、こんな細かいところまでフォローしていないので(きりがなくなるだろ!)こういうところに注意!
※MySQLソケットに関する説明は ぐぐるか
http://yut.hatenablog.com/entry/20110210/1297343942
などを参照
mysql_configの位置を確認
今回の場合、XAMPPに付属していたMySQLを利用するので
/Applications/XAMPP/xamppfiles/bin/mysql_config
が、引用しているファイルになります。
あとあと使います。
ソケットの位置を確認
version='5.6.20'
socket='/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock'
ldflags=''
この中で、ソケットのパス
socket='/Applications/XAMPP/xamppfiles/var/mysql/
に注目。MySQLにアクセスするときなどに使います。
コンパイラを指定する
コンパイラの指定をしてあげないと、インストール時にトラブルが発生しました。
# cflags="-I$pkgincludedir -I/Applications/XAMPP/xamppfiles/include/c-client -I/Applications/XAMPP/xamppfiles/include/libpng -I/Applications/XAMPP/xamppfiles/include/freetype2 -O3 -L/Applications/XAMPP/xamppfiles/lib -I/Applications/XAMPP/xamppfiles/include -I/Applications/XAMPP/xamppfiles/include/ncurses -arch x86_64 -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
# cxxflags="-I$pkgincludedir -I/Applications/XAMPP/xamppfiles/include/c-client -I/Applications/XAMPP/xamppfiles/include/libpng -I/Applications/XAMPP/xamppfiles/include/freetype2 -I/Applications/XAMPP/xamppfiles/include/ncurses -O3 -L/Applications/XAMPP/xamppfiles/lib -I/Applications/XAMPP/xamppfiles/include -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
cflags="-I$pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
cxxflags="-I$pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
参考:Homebrew環境にてmysql2のgemをインストールするときのエラー回避策
ようやく、mysql2のインストール
さきほどのmysql.socketの設定を使い、 mysql2をインストールします。gem
gem install mysql2 -- —-with-mysql-config=/Applications/xampp/xamppfiles/bin/mysql_config
bundle
bundle config build.mysql2 — --with-mysql-config=/Applications/xampp/xamppfiles/bin/mysql_config
以上、一般的なインストールの手順の場合と、MySQLの位置が異なるケースでした。