diff options
author | Andre Arko <andre@arko.net> | 2010-04-19 23:18:07 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2010-04-23 10:02:39 -0700 |
commit | a20c08aee8a8a727ecc94b9ae9e556fb4eb32dc9 (patch) | |
tree | af61205c270d808940c3766d145022cf42217a9b | |
parent | 9810e3803b43f5d620206aba310746371fc2e64e (diff) | |
download | bundler-a20c08aee8a8a727ecc94b9ae9e556fb4eb32dc9.tar.gz |
Fetch full arch from RemoteSpecifications before installing
It turns out quick gem indexes don't include the arch in the platform
string. So we have to fetch the full spec before we install or risk
trying to install the wrong arch.
You'll need to `rm -rf tmp/gems/base` for this to pass the first time.
Cleanups or suggestions on how to make this spec less ugly would also
be welcome.
Closes #277
-rw-r--r-- | lib/bundler/remote_specification.rb | 9 | ||||
-rw-r--r-- | lib/bundler/source.rb | 1 | ||||
-rw-r--r-- | spec/install/gems/simple_case_spec.rb | 32 | ||||
-rw-r--r-- | spec/support/builders.rb | 8 | ||||
-rw-r--r-- | spec/support/rubygems_ext.rb | 4 |
5 files changed, 51 insertions, 3 deletions
diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb index cac0f99b..ee5a8068 100644 --- a/lib/bundler/remote_specification.rb +++ b/lib/bundler/remote_specification.rb @@ -17,6 +17,12 @@ module Bundler @source_uri = source_uri end + # Needed before installs, since the arch matters then and quick + # specs don't bother to include the arch in the platform string + def fetch_platform + @platform = _remote_specification.platform + end + def full_name if platform == Gem::Platform::RUBY or platform.nil? then "#{@name}-#{@version}" @@ -26,7 +32,7 @@ module Bundler end # Because Rubyforge cannot be trusted to provide valid specifications - # once the remote gem is donwloaded, the backend specification will + # once the remote gem is downloaded, the backend specification will # be swapped out. def __swap__(spec) @specification = spec @@ -36,6 +42,7 @@ module Bundler def _remote_specification @specification ||= begin + Bundler.ui.debug "Fetching spec for #{full_name}" Gem::SpecFetcher.new.fetch_spec([@name, @version, @platform], URI(@source_uri.to_s)) end end diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index 02fd8228..5c127b2e 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -41,6 +41,7 @@ module Bundler def fetch(spec) Bundler.ui.debug " * Downloading" uri = @spec_uri_map[[spec.name, spec.version, spec.platform]] + spec.fetch_platform Gem::RemoteFetcher.fetcher.download(spec, uri, Gem.dir) end diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb index 70a148fd..d3296eb0 100644 --- a/spec/install/gems/simple_case_spec.rb +++ b/spec/install/gems/simple_case_spec.rb @@ -398,4 +398,36 @@ describe "bundle install with gem sources" do err.should be_empty end end + + describe "when the gem has an architecture in its platform" do + it "still installs correctly" do + gemfile <<-G + # Set up pretend http gem server with FakeWeb + $LOAD_PATH.unshift '#{Dir[base_system_gems.join("gems/fakeweb*/lib")].first}' + require 'fakeweb' + FakeWeb.allow_net_connect = false + files = [ 'specs.4.8.gz', + 'quick/Marshal.4.8/rcov-1.0-mswin32.gemspec.rz', + 'gems/rcov-1.0-mswin32.gem' ] + files.each do |file| + FakeWeb.register_uri(:get, "http://localgemserver.com/\#{file}", + :body => File.read("#{gem_repo1}/\#{file}")) + end + + missing = [ 'prerelease_specs.4.8.gz', + 'gems/rcov-1.0-x86-mswin32.gem' ] + missing.each do |missing| + FakeWeb.register_uri(:get, "http://localgemserver.com/\#{missing}", + :status => ["404", "Not Found"]) + end + + # Try to install gem with nil arch + source "http://localgemserver.com/" + Gem.platforms = [#{mswin}] + gem "rcov" + G + bundle :install + should_be_installed "rcov 1.0.0" + end + end end diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 4ace2615..5f470e02 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -131,11 +131,13 @@ module Spec s.add_c_extension end + # The bundler 0.8 gem has a rubygems plugin that always loads :( build_gem "bundler", "0.8.1" do |s| s.write "lib/bundler/omg.rb", "" s.write "lib/rubygems_plugin.rb", "require 'bundler/omg' ; puts 'FAIL'" end + # The yard gem iterates over Gem.source_index looking for plugins build_gem "yard" do |s| s.write "lib/yard.rb", <<-Y Gem.source_index.find_name('').each do |gem| @@ -144,6 +146,12 @@ module Spec Y end + # The rcov gem is platform mswin32, but has no arch + build_gem "rcov" do |s| + s.platform = Gem::Platform.new([nil, "mswin32", nil]) + s.write "lib/rcov.rb", "RCOV = '1.0.0'" + end + # Test comlicated gem dependencies for install build_gem "net_a" do |s| s.add_dependency "net_b" diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index 092e4a7d..9f38fe2d 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -9,8 +9,8 @@ module Spec unless File.exist?("#{Path.base_system_gems}") FileUtils.mkdir_p(Path.base_system_gems) - puts "running `gem install builder rake --no-rdoc --no-ri`" - `gem install builder rake --no-rdoc --no-ri` + puts "running `gem install builder rake fakeweb --no-rdoc --no-ri`" + `gem install builder rake fakeweb --no-rdoc --no-ri` end ENV['HOME'] = Path.home.to_s |