summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-07-24 19:46:19 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-07-24 21:22:39 +0200
commitc7532ced89bbc8ddc7296c56391c1c3cc981c54a (patch)
tree1b43595a9eb4d8641c113420192bd02c79014eb6
parent5978a88f337b21f7210c1452533251f9332594fe (diff)
downloadbundler-consistent_lockfiles.tar.gz
Fix inconsistent lockfile orderconsistent_lockfiles
When Gemfile would specify path sources as relative paths starting with "./", the lockfile would have inconsistent order on `bundle install` and `bundle update`.
-rw-r--r--lib/bundler/source/path.rb7
-rw-r--r--spec/install/gemfile/path_spec.rb44
2 files changed, 50 insertions, 1 deletions
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 05d4d78bb5..f98f5155fb 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -24,7 +24,12 @@ module Bundler
if options["path"]
@path = Pathname.new(options["path"])
- @path = expand(@path) unless @path.relative?
+ expanded_path = expand(@path)
+ @path = if @path.relative?
+ expanded_path.relative_path_from(root_path.expand_path)
+ else
+ expanded_path
+ end
end
@name = options["name"]
diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb
index 36750eaf8f..3f2e5bdfc3 100644
--- a/spec/install/gemfile/path_spec.rb
+++ b/spec/install/gemfile/path_spec.rb
@@ -83,6 +83,50 @@ RSpec.describe "bundle install with explicit source paths" do
end
end
+ it "sorts paths consistently on install and update when they start with ./" do
+ build_lib "demo", :path => lib_path("demo")
+ build_lib "aaa", :path => lib_path("demo/aaa")
+
+ gemfile = <<-G
+ gemspec
+ gem "aaa", :path => "./aaa"
+ G
+
+ File.open(lib_path("demo/Gemfile"), "w") {|f| f.puts gemfile }
+
+ lockfile = <<~L
+ PATH
+ remote: .
+ specs:
+ demo (1.0)
+
+ PATH
+ remote: aaa
+ specs:
+ aaa (1.0)
+
+ GEM
+ specs:
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ aaa!
+ demo!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ Dir.chdir(lib_path("demo")) do
+ bundle :install
+ expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
+ bundle :update, :all => true
+ expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
+ end
+ end
+
it "expands paths when comparing locked paths to Gemfile paths" do
build_lib "foo", :path => bundled_app("foo-1.0")