summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2010-04-19 23:18:07 -0700
committerAndre Arko <andre@arko.net>2010-04-19 23:23:23 -0700
commit20d36fd9a575a88f3b13f8ac6f3fd2bcf9482ea6 (patch)
treec2353bc163fb01583e8952cf690d6a53800a21f4
parent9f52e40ede427423afce379f208aacc3854de145 (diff)
downloadbundler-20d36fd9a575a88f3b13f8ac6f3fd2bcf9482ea6.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.rb9
-rw-r--r--lib/bundler/source.rb1
-rw-r--r--spec/install/gems/simple_case_spec.rb32
-rw-r--r--spec/support/builders.rb8
-rw-r--r--spec/support/rubygems_ext.rb4
5 files changed, 51 insertions, 3 deletions
diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb
index cac0f99b30..ee5a8068ff 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 4eed42efbb..cccf031fd1 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -27,6 +27,7 @@ module Bundler
def fetch(spec)
Bundler.ui.debug " * Downloading"
+ 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 6b848fdacd..58cbb46346 100644
--- a/spec/install/gems/simple_case_spec.rb
+++ b/spec/install/gems/simple_case_spec.rb
@@ -395,4 +395,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 59b15e24e1..bff998e992 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -123,11 +123,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", <<-RUBY
Gem.source_index.find_name('').each do |gem|
@@ -136,6 +138,12 @@ module Spec
RUBY
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 092e4a7d99..9f38fe2dff 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