Last Updated: February 25, 2016
·
4.053K
· barnabyalter

Linking to a gem tag from a git repository in Gemfile

It is sometimes useful to link directly to a gem's git repository, e.g. for edge code or for a gem that is not shared through RubyGems.

We have one such case at NYU Libraries for our shared assets engine gem which has some customizations off Twitter Bootstrap for Rails 3. In the Gemfiles of the applications that use these shared assets we have the line:

gem 'nyulibraries_assets', :git => 'git://github.com/NYULibraries/nyulibraries_assets.git'

Because this gem is not packaged and versioned in RubyGems when we make non-backwards-compatible upgrades and can't always immediately upgrade all our apps, we can do one of the following things (or both in succession):

  • In the development stage we can link to the branch specifically:

    gem 'nyulibraries_assets', :git => 'git://github.com/NYULibraries/nyulibraries_assets.git', :branch => 'development'
  • Once we're ready to merge back to master, let's tag the last working commit for non-upgraded apps, then merge back to master:

    git tag -a v1.0 -m 'Stable v1.0 before template changes'
    git push --tags

Then link to this version in your older apps until you have the time to upgrade:

gem 'nyulibraries_assets', :git => 'git://github.com/NYULibraries/nyulibraries_assets.git', :tag => 'v1.0'

Resources

2 Responses
Add your response

Cool!

over 1 year ago ·

Indirectly related: note that bundler will not install git gems to the system gems.

over 1 year ago ·