LoginSignup
41
40

More than 5 years have passed since last update.

bundle execを使わずにすむ方法

Last updated at Posted at 2012-12-26

rbenvの場合はこちら

前置き

  • プロジェクトで使うライブラリはできるだけbundlerで管理したい。
  • でも、いちいちbundle exec rails sとかやるのめんどい。
  • alias be="bundle exec"としてbe rails sってやるのもめんどくさくなってきた。
  • なんかいい方法ないの?ってことで調べたら、すぐ見つかったのでご紹介。

まとめ

  1. rvmのフックスクリプトに実行権限を与える
  2. --binstubsをつけてbundle install

具体例

$ cd
$ chmod +x .rvm/hooks/after_cd_bundler
$ cd workspaces/sampleapp
$ vi Gemfile
Gemfile
source "http://rubygems.org"
gem "heroku"
$ bundle install --path vendor/bundle --binstubs
$ ls
Gemfile Gemfile.lock bin vendor
$ cd
$ cd workspaces/sampleapp
$ heroku --version
heroku-gem/2.20.0

解説

  • .rvm/hooks/after_cd_bundle.bundleディレクトリが存在するプロジェクトにcdで移動したとき実行されるスクリプトで、--binstubsオプションで生成されたbinディレクトリにパスを渡す。
  • --binstubsオプションはbundle installでインストールされたライブラリの実行スクリプトをbinディレクトリのなかに生成する。

参考

41
40
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
41
40