diff options
author | Agrim Mittal <agrimmittal97@gmail.com> | 2018-04-05 20:06:54 +0530 |
---|---|---|
committer | Agrim Mittal <agrimmittal97@gmail.com> | 2018-04-07 09:38:06 +0530 |
commit | a3fbedc2d02c8f6b6d7281c7659f28be9d89dfee (patch) | |
tree | e85a6eeb654db9f3f029b6ddd25a925a5945a16a | |
parent | 257fb54da0003c3a67f6e7b3b5a242a4ba9c45cb (diff) | |
download | bundler-a3fbedc2d02c8f6b6d7281c7659f28be9d89dfee.tar.gz |
Fix bundle lock when default gemfile is present
-rw-r--r-- | lib/bundler/definition.rb | 3 | ||||
-rw-r--r-- | spec/commands/lock_spec.rb | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 91d34ad150..bec3cadbb4 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -337,7 +337,8 @@ module Bundler end preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler)) - return if lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections) + + return if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections) if Bundler.frozen_bundle? Bundler.ui.error "Cannot write a changed lockfile while frozen." diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index bd5bdfff2f..81eba1ceda 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -97,6 +97,14 @@ RSpec.describe "bundle lock" do expect { read_lockfile }.to raise_error(Errno::ENOENT) end + it "writes to custom location using --lockfile when a default lockfile is present" do + bundle "install" + bundle "lock --lockfile=lock" + + expect(out).to match(/Writing lockfile to.+lock/) + expect(read_lockfile("lock")).to eq(@lockfile) + end + it "update specific gems using --update" do lockfile @lockfile.gsub("2.3.2", "2.3.1").gsub("10.0.2", "10.0.1") |