LoginSignup
5
3

More than 5 years have passed since last update.

bundle execを省略してみる

Last updated at Posted at 2017-05-03

Railsのバージョンを4と5で共存させたいので基本的にはgemをプロジェクトごとに管理してますが、いちいちbundle execをつけるのは面倒です。

探してると、それを省略できるやり方があるのを見つけました。
MacOSX Sierraでやる場合とrailsコマンドのエイリアスがなかったので、少し自分用に変えたやり方です。

bundle-exec.shを使う

$ curl -L https://github.com/gma/bundler-exec/raw/master/bundler-exec.sh > ~/.bundler-exec.sh
$ vi ~/.bundler-exec.sh
//最後の方の'BUNDLED_COMMANDS="${BUNDLED_COMMANDS:-'以下のコマンドが書かれた箇所にrailsを追加します。
$ echo "[ -f ~/.bundler-exec.sh ] && source ~/.bundler-exec.sh" >> ~/.bash_profile
$ source .bash_profile
$ type ruby
ruby is aliased to `run-with-bundler ruby'

上記のようになればOK

rubyとかrailsとかのコマンドにエイリアスをつけて、プロジェクトディレクトリ内で実行した場合には、自動的にbundle execをつけて実行してくれるようです。

便利。

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3