For a while, I’ve been keeping bundled gems local to each project. (It’s pretty easy to do: bundle --path .bundle/gems
the first time you bundle a project. I like putting it in .bundle because it’s already gitignored.) This results in a lot of duplicate gems across my system, but it has the advantage of keeping each project very self-contained, and I avoid undesirable side-effects (like rake getting upgraded) just because I bundle
some code from github.
This leads to a pretty sparse set of system gems. But it also makes it a little challenging to bootstrap a new rails project, since there isn’t a current rails
executable! How to avoid installing the latest rails to start a new project?
It’s pretty easy, when you think about it, but it is a little less straightforward.
mkdir -p ~/my/new/awesome_project
cd ~/my/new/awesome_project
echo source :rubygems > Gemfile
echo gem 'rails', '~>3.1.0.rc4' >> Gemfile
bundle --path .bundle
bundle exec rails .
It’ll ask if you want to overwrite Gemfile, which is, of course, fine, because it’s just going to add more gems.