Jamie's Blog

Ruby developer. CTO. Swimmer. Always trying to write more

Stop typing bundle exec with rbenv

It can get a bit tiresome typing bundle exec in front of every Rails command. RVM seems to have this problem solved but I’m using rbenv.

alias b

The quick and dirty way to add this to your .bashprofile/.bashrc file:
alias b='bundle exec'
Now you can just type b rake instead of bundle exec rake


A much cleaner but more complicated method is to use <a title=“rbenv bundler plugin” href=“https://github.com/carsomyr/rbenv-bundler” target=“
blank”>this rbenv-bundler plugin and install your gems into vendor/bundle. The installation instructions are pretty simple and, once installed, you can omit the bundle exec from all your commands entirely. Since it requires you to install all your gems in the vendor/bundle directory, I’d recommend adding that to your .gitignore file.


As an aside, if you now find that your Sublime project is filling with cruft from the bundle’d gems, simply exclude that folder from your project in myproject.sublime-project
            "path": "/Users/jamie/projects/myproject",
            "folderexcludepatterns": ["vendor/bundle"]