bundlerでもオプションを指定したい
通常gemで何かをインストールする際、gemのビルドオプションが必要などといった場合には以下のようにする
gem install charlock_holmes --with-icu-dir=/path/to/installed/icu4c
で、これをbundle installする時はbundle install <ビルドオプション>というようにしてもうまくはいかない。
特にrailsなんかはvendor/bundle以下にgemを配置する事がよくあるのでgemでインストールするときよりも寧ろbundlerを使った際に指定する方法のほうが知りたかったりする。じゃあどうやってやるのか?
bundle config
bundlerを使う時は以下のように行う
bundle config build.charlock_holmes --with-icu-dir=/path/to/installed/icu4c
charlock_holmesというのがgemの名前。build.のあとにオプションを指定したいgemの名前を入れる。
こうすればcharlock_holmesにのみそのビルドオプションが適用される。
ちなみにただbundle configをだけを打ち込んでみると
Settings are listed in order of priority. The top value will be used.
build.charlock_holmes
Set for the current user (/Users/shim0mura/.bundle/config): "--with-icu-dir=/usr/local/lib"
path
Set for your local app (/Users/shim0mura/work/chef/.bundle/config): "vendor/bundle"
disable_shared_gems
Set for your local app (/Users/shim0mura/work/chef/.bundle/config): "1"
これはbundle config build.charlock_holmes....を実行した後での出力。
Gemfileがあるディレクトリや自分のホームディレクトリの中にある.bundle/configに設定した値が保存されているようだ。