Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Compensate for Rubygems' usage of .gemrc sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Arko and Terence Lee authored and hone committed Dec 8, 2012
1 parent d220daa commit d800773
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lib/bundler/fetcher.rb
Expand Up @@ -200,9 +200,6 @@ def fetch_dependency_remote_specs(gem_names)

# fetch from modern index: specs.4.8.gz
def fetch_all_remote_specs
# Ensure config is loaded so it doesn't get lazy-loaded later, overwriting Gem.sources!
Bundler.rubygems.configuration

@has_api = false
Bundler.rubygems.sources = ["#{@remote_uri}"]

Expand Down
5 changes: 5 additions & 0 deletions lib/bundler/rubygems_integration.rb
Expand Up @@ -35,6 +35,11 @@ def inflate(obj)
end

def sources=(val)
# Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
# If that file exists, its settings (including sources) will overwrite the values we
# are about to set here. In order to avoid that, we force memoizing the config file now.
configuration

Gem.sources = val
end

Expand Down
22 changes: 22 additions & 0 deletions spec/install/gems/dependency_api_spec.rb
Expand Up @@ -433,4 +433,26 @@ def fetch(*)
end
end

context ".gemrc with sources is present" do
before do
File.open(home('.gemrc'), 'w') do |file|
file.puts({:sources => ["http://rubygems.org"]}.to_yaml)
end
end

after do
home('.gemrc').rmtree
end

it "uses other sources declared in the Gemfile" do
gemfile <<-G
source "#{source_uri}"
gem 'rack'
G

bundle "install", :exitstatus => true, :artifice => "endpoint_marshal_fail"

expect(exitstatus).to eq(0)
end
end
end

0 comments on commit d800773

Please sign in to comment.