Ruby Bundler multiple sources in Gemfile

mawk044 picture mawk044 · Apr 18, 2013 · Viewed 14k times · Source

I need to ensure some of my gems are installed from our own gem repository rather than rubygems, while the rest are installed from rubygems. Can I set this up in the Gemfile without worrying about a naming conflict with a identically named gem in Rubygems? How Can I determine where the gem is downloaded from?

eg Gemfile:

source :rubygems  
gem 'gemfromrubygems1'  
gem 'gemfromrubygems2'

source "http://our.own.gem.repo.com/the/path/to/it"  
gem 'gemfromourrepo'

Answer

Tim Moore picture Tim Moore · Aug 14, 2014

Bundler 1.7 has a new feature that allows you to select the source for specific gems by nesting them in a block:

source "https://rubygems.org"

gem 'gemfromrubygems1' 
gem 'gemfromrubygems2'

source "http://our.own.gem.repo.com/the/path/to/it" do
  gem 'gemfromourrepo'
end

or specifying it as an option:

source "https://rubygems.org"

gem 'gemfromrubygems1' 
gem 'gemfromrubygems2'

gem 'gemfromourrepo', source: "http://our.own.gem.repo.com/the/path/to/it"

See http://bundler.io/v1.7/gemfile.html for details.