Skip to content

Commit 28f813b

Browse files
Merge pull request #7034 from rubygems/fix-lock-with-frozen
Make the `lock` command not be affected by the `frozen` setting
2 parents 6f7e7a9 + 1d501ae commit 28f813b

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

bundler/lib/bundler/cli/lock.rb

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,39 @@ def run
3232
elsif update && bundler
3333
update = { :bundler => bundler }
3434
end
35-
definition = Bundler.definition(update)
3635

37-
Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) if options[:update]
36+
Bundler.settings.temporary(:frozen => false) do
37+
definition = Bundler.definition(update)
3838

39-
options["remove-platform"].each do |platform|
40-
definition.remove_platform(platform)
41-
end
39+
Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
4240

43-
options["add-platform"].each do |platform_string|
44-
platform = Gem::Platform.new(platform_string)
45-
if platform.to_s == "unknown"
46-
Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
47-
"and adding it will likely lead to resolution errors"
41+
options["remove-platform"].each do |platform|
42+
definition.remove_platform(platform)
4843
end
49-
definition.add_platform(platform)
50-
end
5144

52-
if definition.platforms.empty?
53-
raise InvalidOption, "Removing all platforms from the bundle is not allowed"
54-
end
45+
options["add-platform"].each do |platform_string|
46+
platform = Gem::Platform.new(platform_string)
47+
if platform.to_s == "unknown"
48+
Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
49+
"and adding it will likely lead to resolution errors"
50+
end
51+
definition.add_platform(platform)
52+
end
5553

56-
definition.resolve_remotely! unless options[:local]
54+
if definition.platforms.empty?
55+
raise InvalidOption, "Removing all platforms from the bundle is not allowed"
56+
end
57+
58+
definition.resolve_remotely! unless options[:local]
5759

58-
if print
59-
puts definition.to_lock
60-
else
61-
file = options[:lockfile]
62-
file = file ? File.expand_path(file) : Bundler.default_lockfile
63-
puts "Writing lockfile to #{file}"
64-
definition.lock(file)
60+
if print
61+
puts definition.to_lock
62+
else
63+
file = options[:lockfile]
64+
file = file ? File.expand_path(file) : Bundler.default_lockfile
65+
puts "Writing lockfile to #{file}"
66+
definition.lock(file)
67+
end
6568
end
6669

6770
Bundler.ui.level = previous_ui_level

bundler/spec/commands/lock_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
bundle "lock --update"
7474

7575
expect(read_lockfile).to eq(@lockfile)
76+
77+
lockfile @lockfile.gsub("2.3.2", "2.3.1")
78+
79+
bundle "lock --update", :env => { "BUNDLE_FROZEN" => "true" }
80+
81+
expect(read_lockfile).to eq(@lockfile)
7682
end
7783

7884
it "does not fetch remote specs when using the --local option" do

0 commit comments

Comments
 (0)