I often want to experiment with a Ruby gem, but don’t want to install it (and all its dependencies) globally on my system. So, I use Bundler to install and use it locally in the project directory. That way I can easily clean the whole thing up when I’m done.
Just start in an empty project dir, and create a
Gemfile that looks like:
source 'https://rubygems.org' gem 'octopress', '~> 3.0' group :jekyll_plugins do gem 'octopress-genesis-theme' end
Now install the gems using bundler. The
--path=vendor is the key that
installs everything into the local dir (in a subdir named
vendor, to be
specific). Once you run it this way once, it creates a
that remembers this setting for subsequent invocations of
$ bundle install --path=vendor Resolving dependencies... Using execjs 2.5.2 Using autoprefixer-rails 18.104.22.16840804 Using blankslate 22.214.171.124 # lots more gems and versions… Bundle complete! 2 Gemfile dependencies, 61 gems now installed. Bundled gems are installed into ./vendor.
Now you just have to prefix the commands that want to use the gem exectuables
$ bundle exec octopress new . --force $ cat >> _config.yml exclude: [vendor] ^D $ bundle exec jekyll serve
Then, when I’m done tinkering, I can delete the whole project dir, and not be left with a bunch of cruft installed in my system.