summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-28 14:32:10 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-28 14:32:10 +0200
commitc0e3e86140c8a38ebc1660a82b4c16dcb239f601 (patch)
tree3c578446e02f7a8ca3c2b5cf7a757a3bc5cdb566
parentf9bd2c16e0c6252be8f96af79c9f394b0cb73277 (diff)
downloadbundler-c0e3e86140c8a38ebc1660a82b4c16dcb239f601.tar.gz
Fix crash when dependency is for another platform
-rw-r--r--lib/bundler/cli/update.rb18
-rw-r--r--spec/commands/update_spec.rb34
2 files changed, 42 insertions, 10 deletions
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index caee156bdd..abb39ae0f5 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -79,21 +79,19 @@ module Bundler
locked_spec = previous_locked_specs[name]
next unless locked_spec
- locked_source = locked_spec[:source]
new_spec = Bundler.definition.specs[name].first
+ next unless new_spec
+
+ locked_source = locked_spec[:source]
new_source = new_spec.source.to_s
next if locked_source != new_source
new_version = new_spec.version
- if !new_version
- Bundler.ui.warn "Bundler attempted to update #{name} but it was removed from the bundle"
- else
- locked_version = locked_spec[:version]
- if new_version < locked_version
- Bundler.ui.warn "Note: #{name} version regressed from #{locked_version} to #{new_version}"
- elsif new_version == locked_version
- Bundler.ui.warn "Bundler attempted to update #{name} but its version stayed the same"
- end
+ locked_version = locked_spec[:version]
+ if new_version < locked_version
+ Bundler.ui.warn "Note: #{name} version regressed from #{locked_version} to #{new_version}"
+ elsif new_version == locked_version
+ Bundler.ui.warn "Bundler attempted to update #{name} but its version stayed the same"
end
end
end
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index 735d8cd8de..bf5cd32ca1 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -563,6 +563,40 @@ RSpec.describe "bundle update in more complicated situations" do
expect(the_bundle).to include_gem "a 1.1"
end
end
+
+ context "when the dependency is for a different platform" do
+ before do
+ build_repo4 do
+ build_gem("a", "0.9") {|s| s.platform = "java" }
+ build_gem("a", "1.1") {|s| s.platform = "java" }
+ end
+
+ gemfile <<-G
+ source "file://#{gem_repo4}"
+ gem "a", platform: :jruby
+ G
+
+ lockfile <<-L
+ GEM
+ remote: file://#{gem_repo4}
+ specs:
+ a (0.9-java)
+
+ PLATFORMS
+ java
+
+ DEPENDENCIES
+ a
+ L
+
+ simulate_platform linux
+ end
+
+ it "is not updated because it is not actually included in the bundle" do
+ bundle! "update a"
+ expect(the_bundle).to_not include_gem "a"
+ end
+ end
end
RSpec.describe "bundle update without a Gemfile.lock" do