From 42363091dafb843a6ee40a7dfebd387699272271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 24 Jul 2019 19:45:53 +0200 Subject: [PATCH 1/3] Reuse `root` method --- lib/bundler/source/path.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index c1d25fc4dad..05d4d78bb58 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -20,7 +20,7 @@ def initialize(options) @allow_cached = false @allow_remote = false - @root_path = options["root_path"] || Bundler.root + @root_path = options["root_path"] || root if options["path"] @path = Pathname.new(options["path"]) @@ -136,7 +136,7 @@ def expand(somepath) def lockfile_path return relative_path(original_path) if original_path.absolute? - expand(original_path).relative_path_from(Bundler.root) + expand(original_path).relative_path_from(root) end def app_cache_path(custom_path = nil) From 5978a88f337b21f7210c1452533251f9332594fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 24 Jul 2019 19:48:10 +0200 Subject: [PATCH 2/3] Indentation tweak --- spec/install/gemfile/path_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index cfd85ac73f2..36750eaf8f5 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -370,13 +370,13 @@ end it "works when the path does not have a gemspec but there is a lockfile" do - lockfile <<-L - PATH - remote: vendor/bar - specs: + lockfile <<~L + PATH + remote: vendor/bar + specs: - GEM - remote: http://rubygems.org + GEM + remote: http://rubygems.org L in_app_root { FileUtils.mkdir_p("vendor/bar") } From c7532ced89bbc8ddc7296c56391c1c3cc981c54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 24 Jul 2019 19:46:19 +0200 Subject: [PATCH 3/3] Fix inconsistent lockfile order When Gemfile would specify path sources as relative paths starting with "./", the lockfile would have inconsistent order on `bundle install` and `bundle update`. --- lib/bundler/source/path.rb | 7 ++++- spec/install/gemfile/path_spec.rb | 44 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 05d4d78bb58..f98f5155fb5 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -24,7 +24,12 @@ def initialize(options) 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 36750eaf8f5..3f2e5bdfc30 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -83,6 +83,50 @@ 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")