Mac に Groonga/Mroonga 3.0.0 を homebrew でインストールする際にはまったこと

開発者さんによると今はもう大丈夫とのことです :)

                  • -

Groonga のインストール時に必要なライブラリへのパスをうまく通せていなくて悩みました ;) 同じところでひっかかる人いるんじゃないかなと思いメモを残しておきます。

brew でインストールしようとして …

$ brew install https://raw.github.com/mroonga/homebrew/master/mroonga.rb --use-homebrew-mysql

なんとなくうまくいったかなと思って、mysql で show engines をして見るも Mroonga ない …。インストール時の出力を見てみると Groonga のインストール (Mroonga と関連しているから上のコマンドで一緒に入る) 中に以下のエラーが出ていました。

and GROONGA_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

To get pkg-config, see http://pkg-config.freedesktop.org/.
See `config.log' for more details

GROONGA_CFLAGS と GROONGA_LIBS を指定するとうまくいくよというアドバイスがあって、「GROONGA_CFLAGS="-I/usr/local/include/groonga"」をコンソールにコピーしてエンター!
Homebrew で mroonga 3.00 インストールの際、pkg-config に怒られたら - Qiita

でも、よく見ると「Shell script」と書いてある、、、コンソールで指定する時は "export" 頭につけないとだめ。。。そりゃそうですね。コピペ、えい!… あれ … ? を繰り返していました。ばかばか ;) 以下のようにします:

$ export GROONGA_CFLAGS="-I/usr/local/include/groonga"
$ export GROONGA_LIBS="-L/usr/local/lib -lgroonga"

無事インストールされた時の出力を貼りつけておきます。

$ brew install https://raw.github.com/mroonga/homebrew/master/mroonga.rb --use-homebrew-mysql
######################################################################## 100.0%

==> Downloading http://packages.groonga.org/source/mroonga/mroonga-3.00.tar.gz
Already downloaded: /Users/akipponn/Library/Caches/Homebrew/mroonga-3.00.tar.gz
==> Downloading http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from/http://cdn.mysql.com/
Already downloaded: /Users/akipponn/Library/Caches/Homebrew/mysql-5.6.10.com
==> ./configure --prefix=/usr/local/Cellar/mroonga/3.00 --with-mysql-source=/private/tmp/mysql-nLLG/mysql-5.6.10 --with-mysql-config=/usr/local/Cellar/mysql/5.6.10/bin/mysql_config
==> make
==> make install
==> mysql -uroot -e 'INSTALL PLUGIN mroonga SONAME "ha_mroonga.so"; CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME "ha_mroonga.so"; CREATE FUNCTION mroonga_snippet RETURN
==> Caveats
To install mroonga plugin, run the following command:
mysql -uroot -e 'INSTALL PLUGIN mroonga SONAME "ha_mroonga.so"; CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME "ha_mroonga.so"; CREATE FUNCTION mroonga_snippet RETURNS STRING SONAME "ha_mroonga.so";'

To confirm successfuly installed, run the following command
and confirm that 'mroonga' is in the list:

mysql> SHOW PLUGINS;
+---------+--------+----------------+---------------+---------+
| Name | Status | Type | Library | License |
+---------+--------+----------------+---------------+---------+
| ... | ... | ... | ... | ... |
| mroonga | ACTIVE | STORAGE ENGINE | ha_mroonga.so | GPL |
+---------+--------+----------------+---------------+---------+
XX rows in set (0.00 sec)
==> Summary
🍺 /usr/local/Cellar/mroonga/3.00: 149 files, 2.6M, built in 33 seconds

やったー :)