bundle execを使わずに済む方法(rbenv編)

$ cd
$ mkdir .rbenv/plugins
$ cd .rbenv/plugins
$ git clone git://github.com/ianheggie/rbenv-binstubs.git
  • rbenvにはpluginsという仕組みがあってrbenvに機能を追加できる。ruby-buildもその一つ。「ひとつのことをうまくやる」思想っぽい。
  • そのpluginのひとつにbundlerとの連携をうまくやってくれるrbenv-bundlerというのがあるんだけど、rbenvはこれを非推奨といってる。パフォーマンスが悪くなったり、バグが多いみたい。
  • 同じようなpluginを探したところ、rbenv-binstubsというものを見つけた。thoughtbotのブログで紹介されていた。

Rails 3

$ cd path/to/project
$ bundle install --binstubs
$ rbenv rehash
$ rails s
  • --path=vendor/bundleを指定するとうまくいかなかった。

Rails 4

$ cd path/to/project
$ bundle install --binstubs=bundle_bin
$ rbenv rehash
$ rails s
  • Rails 4からはbinディレクトリの扱いが若干変わるので要注意。詳しくはこちら
  • binstubsが実行ファイルを生成するディレクトリを指定する。指定してもちゃんと動く。