bundle lock does not respect Gemfile lockfile
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 4k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 81
Description
Describe the problem as clearly as you can
#9059 introduced the ability to specify the lockfile path via the Gemfile DSL:
lockfile "Gemfile_next.lock"
However, bundle lock does not appear to use that value when writing the lock file.
From reading the implementation, this looks like it may be because Bundler::CLI::Lock falls back to Bundler.default_lockfile unless the command is called with the explicit --lockfile option.
Did you try upgrading rubygems & bundler?
The issue is present with version 4.0.12 of Bundler.
Post steps to reproduce the problem
- Create a project with a minimal Gemfile specifying a custom lockfile path (see the the
bundle envoutput below for an example) - Run
bundle lock - See that the lockfile is written to the default path, not the path specified in the Gemfile
Which command did you run?
bundle lock
What were you expecting to happen?
The lockfile is written to the path passed to lockfile in the Gemfile.
What happened instead?
The lockfile is written to the default lockfile path, i.e. Gemfile.lock.
If not included with the output of your command, run bundle env and paste the output below
Environment
Bundler 4.0.12
Platforms ruby, arm64-darwin-25
Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721) [arm64-darwin-25]
Full Path /Users/thom.carter/.asdf/installs/ruby/4.0.5/bin/ruby
Config Dir /Users/thom.carter/.asdf/installs/ruby/4.0.5/etc
RubyGems 4.0.10
Gem Home /Users/thom.carter/.asdf/installs/ruby/4.0.5/lib/ruby/gems/4.0.0
Gem Path /Users/thom.carter/.gem/ruby/4.0.0:/Users/thom.carter/.asdf/installs/ruby/4.0.5/lib/ruby/gems/4.0.0
User Home /Users/thom.carter
User Path /Users/thom.carter/.gem/ruby/4.0.0
Bin Dir /Users/thom.carter/.asdf/installs/ruby/4.0.5/bin
Tools
Git 2.52.0
RVM not installed
rbenv not installed
chruby not installed
Bundler Build Metadata
Timestamp 2026-05-26
Git SHA 665f998196
Gemfile
Gemfile
source "https://rubygems.org"
gem "rack"
lockfile "Gemfile_next.lock"
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
rack (3.2.6)
PLATFORMS
arm64-darwin-25
ruby
DEPENDENCIES
rack
CHECKSUMS
bundler (4.0.12) sha256=7f8b757d28dfb636e7b24fba2344ac6dd13b5b24f4b46d62573d483f211825ac
rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2
BUNDLED WITH
4.0.12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Bundler::CLI::Lock and trace how the command selects its lockfile when no explicit --lockfile option is given. Reproduce the issue with a minimal Gemfile containing lockfile "Gemfile_next.lock" and run bundle lock; done means the lockfile is written to the Gemfile-specified path rather than Gemfile.lock.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100