Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Fix inconsistent lockfile order
Browse files Browse the repository at this point in the history
When Gemfile would specify path sources as relative paths starting with
"./", the lockfile would have inconsistent order on `bundle install` and
`bundle update`.
  • Loading branch information
deivid-rodriguez committed Jul 24, 2019
1 parent 5978a88 commit 2a50f33
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/bundler/source/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
44 changes: 44 additions & 0 deletions spec/install/gemfile/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,50 @@
end
end

it "sorts expanded paths consistently on install and update" 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
ruby
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")

Expand Down

0 comments on commit 2a50f33

Please sign in to comment.