How to Vendor Gem a Gem
Gems offer prebuilt software components for the Ruby / Rails space. What they don't offer, when used as a gem, is the ability to modify their source code. Unlike a traditional Rails plugin which was installed into your application tree, gems tend to exist in a magical, hidden bundle location. When you can do, however, is "vendor gem" them so that you can easily modify / update them. Ideally we'd all make our changes as pull requests against the canonical git repo but sometimes there isn't time. So here are the steps:
- Install a gem into your Gemfile.
- run bundler: bundle install
- Unpack it. Here's an example:
gem unpack anemone
- This will put it into the root dir of your Rails application so now move it to vendor/gems:
mv anemone-0.7.2 vendor/gems
- Go into your gem file and modify the line:
gem 'anemone'
to look something like this:
gem 'anemone', '0.7.2', :path => "vendor/gems/anemone-0.7.2" - run bundler again:
bundle install - Git add / commit / push
Thanks to Jared for helping me (once again) with this. Hopefully now that I took the time to document it, it won't be as hard next timeā¦
Posted In: #ruby #gem #vendor gem