Search code examples
bundler

Gemfile: A better way to conditionally declare local or remote gems for multiple developers


Our group has several people, any number of which may be working on any combination of gems. Currently, our Gemfile has stuff like this:

gem 'awesome-gem', :git => 'git@github.com:somebody/awesome-gem.git'
# gem 'awesome-gem', :path => '/Users/developer-A/workspace/awesome-gem'

# gem 'rad-gem', :git => 'git@github.com:somebody/rad-gem.git', :branch => 'release'
gem 'rad-gem', :path => '/some/path/specific-to/developer-B/rad-gem'

So developer-A was working on awesome-gem locally, and when they finished up, they just replaced their :path the gem's :git location and committed both to version control. developer-B and C do the same thing for rad-gem, each has a different :path in their locally modified Gemfile and if the Gemfile every has real changes, they have to undo their local :path setup, commit, undo to point back to their local version of rad-gem, etc.

This is both a pain and ugly, so I tried to come up with a better solution but the best I could come up with is something like this:

if ENV['RADGEM_PATH']
  gem 'rad-gem', :path => ENV['RADGEM_PATH']
else
  gem 'rad-gem', :git => 'git@github.com:somebody/rad-gem.git', :branch => 'release'
end

This allows developer-B and C to set their own rad-gem path while removing much of the pain mentioned above. however, it is still ugly and I'm wondering if there is a better way to do this, possibly using groups?


Solution

  • Update (current)

    A recent update to bunder now provides local git repos. This is the current way of solving this problem. Thank you sekrett

    Update (outdated)

    If you have Bundler >= 1.2, there is now a better way to do this. For example,

    bundle config local.blog ~/Work/gems/blog
    

    original answer (outdated)

    A friend of mine on the rspec core team showed me the approach they used in the rspec-core Gemfile, so I guess I'll use that.