diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2018-02-03 13:12:57 -0800 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2018-02-03 13:12:57 -0800 |
commit | 40cb76eedadb43389103c7691b83432357eb33eb (patch) | |
tree | 1727a20191c969361c02362f8f741f63433bc6ed | |
parent | bf7d54818a49b07d2145aecff104fa866ff45d47 (diff) | |
download | bundler-40cb76eedadb43389103c7691b83432357eb33eb.tar.gz |
[Definition] Gracefully handle when the lockfile is missing specs needed to run on the current platform
-rw-r--r-- | lib/bundler/definition.rb | 8 | ||||
-rw-r--r-- | spec/runtime/platform_spec.rb | 32 |
2 files changed, 38 insertions, 2 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index b30ae81623..0349af39f2 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -76,6 +76,7 @@ module Bundler @lockfile_contents = String.new @locked_bundler_version = nil @locked_ruby_version = nil + @locked_specs_incomplete_for_platform = false if lockfile && File.exist?(lockfile) @lockfile_contents = Bundler.read_file(lockfile) @@ -529,7 +530,7 @@ module Bundler private :sources def nothing_changed? - !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes + !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@locked_specs_incomplete_for_platform end def unlocking? @@ -556,6 +557,7 @@ module Bundler [@new_platform, "you added a new platform to your gemfile"], [@path_changes, "the gemspecs for path gems changed"], [@local_changes, "the gemspecs for git local gems changed"], + [@locked_specs_incomplete_for_platform, "the lockfile does not have all gems needed for the current platform"], ].select(&:first).map(&:last).join(", ") end @@ -802,7 +804,9 @@ module Bundler end resolve = SpecSet.new(converged) - resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems], false, false, false) + expanded_deps = expand_dependencies(deps, true) + @locked_specs_incomplete_for_platform = !resolve.for(expanded_deps, @unlock[:gems], true, true) + resolve = resolve.for(expanded_deps, @unlock[:gems], false, false, false) diff = nil # Now, we unlock any sources that do not have anymore gems pinned to it diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb index f38f733845..eecf162427 100644 --- a/spec/runtime/platform_spec.rb +++ b/spec/runtime/platform_spec.rb @@ -115,4 +115,36 @@ RSpec.describe "Bundler.setup with multi platform stuff" do expect(the_bundle).to include_gems "platform_specific 1.0 RUBY" end end + + it "recovers when the lockfile is missing a platform-specific gem" do + build_repo2 do + build_gem "requires_platform_specific" do |s| + s.add_dependency "platform_specific" + end + end + simulate_windows x64_mingw do + lockfile <<-L + GEM + remote: file:#{gem_repo2}/ + specs: + platform_specific (1.0-x86-mingw32) + requires_platform_specific (1.0) + platform_specific + + PLATFORMS + x64-mingw32 + x86-mingw32 + + DEPENDENCIES + requires_platform_specific + L + + install_gemfile! <<-G, :verbose => true + source "file://#{gem_repo2}" + gem "requires_platform_specific" + G + + expect(the_bundle).to include_gem "platform_specific 1.0 x64-mingw32" + end + end end |