Skip to content

Respect Gemfile lockfile in bundle lock#9661

Open
davidstosik wants to merge 1 commit into
ruby:masterfrom
davidstosik:sto/bundle-lock-lockfile
Open

Respect Gemfile lockfile in bundle lock#9661
davidstosik wants to merge 1 commit into
ruby:masterfrom
davidstosik:sto/bundle-lock-lockfile

Conversation

@davidstosik

@davidstosik davidstosik commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #9565.

What was the end-user or developer problem that led to this PR?

As described in the issue linked above, when Gemfile specifies a custom lockfile name using lockfile, and the user runs bundle lock, the lock file gets written to Gemfile.lock instead of the specified name.

What is your fix for the problem, implemented in this PR?

Use definition.lockfile as a fallback instead of Bundler.default_lockfile.

You can confirm the problem easily:

$ mkdir /tmp/test_bundle && cd /tmp/test_bundle

$ bundle --version
4.0.15

$ cat > Gemfile <<-G 
gem "rails"
lockfile "custom.lock"
G

$ bundle lock
Writing lockfile to /private/tmp/test_bundle/Gemfile.lock
Resolving dependencies...

$ ls
Gemfile      Gemfile.lock

I also wrote a test that would fail without the fix in this PR, and now passes.

Make sure the following tasks are checked

Use the lockfile path resolved from the definition when no explicit `--lockfile` option is passed.
@davidstosik davidstosik force-pushed the sto/bundle-lock-lockfile branch from d41ac1b to 9e9e2e5 Compare July 1, 2026 13:20
@davidstosik davidstosik marked this pull request as ready for review July 1, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bundle lock does not respect Gemfile lockfile

1 participant