From e920ee32894dcd2ab0f97ff6f45c29d65024da0c Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Sat, 22 Nov 2025 20:31:14 -0800 Subject: [ruby/rubygems] Support bundle install --lockfile option This allows for specifying the lockfile to read and write. It mirrors the --gemfile option, and has higher priority than the lockfile method in the Gemfile. It also mirrors the bundle lock --lockfile option. When the --lockfile option is used, it is applied twice. First, before the Gemfile is read, to specify the lockfile to operate on, and again after the Gemfile is read, so that if the Gemfile has a lockfile method that overrides the defintion's lockfile, the --lockfile option still has higher precedence. https://github.com/ruby/rubygems/commit/17acdd4a89 --- spec/bundler/commands/install_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'spec') diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 69d9a86099..bacd8d64f2 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -41,6 +41,17 @@ RSpec.describe "bundle install with gem sources" do expect(bundled_app("OmgFile.lock")).to exist end + it "creates lockfile based on --lockfile option is given" do + gemfile bundled_app("OmgFile"), <<-G + source "https://gem.repo1" + gem "myrack", "1.0" + G + + bundle "install --gemfile OmgFile --lockfile ReallyOmgFile.lock" + + expect(bundled_app("ReallyOmgFile.lock")).to exist + end + it "does not make a lockfile if lockfile false is used in Gemfile" do install_gemfile <<-G lockfile false @@ -100,6 +111,18 @@ RSpec.describe "bundle install with gem sources" do expect(bundled_app("OmgFile.lock")).not_to exist end + it "doesn't create a lockfile if --no-lock and --lockfile options are given" do + gemfile bundled_app("OmgFile"), <<-G + source "https://gem.repo1" + gem "myrack", "1.0" + G + + bundle "install --gemfile OmgFile --no-lock --lockfile ReallyOmgFile.lock" + + expect(bundled_app("OmgFile.lock")).not_to exist + expect(bundled_app("ReallyOmgFile.lock")).not_to exist + end + it "doesn't delete the lockfile if one already exists" do install_gemfile <<-G source "https://gem.repo1" -- cgit v1.2.3