Skip to content

Restore lockfile pinning and section handling lost in the Bundler parser switch - #9811

Merged
hsbt merged 4 commits into
masterfrom
fix/request-set-lockfile-bang-pinning
Aug 27, 2026
Merged

hsbt merged 4 commits into
masterfrom
fix/request-set-lockfile-bang-pinning

Conversation

@hsbt

@hsbt hsbt commented Aug 26, 2026

Copy link
Copy Markdown
Member

The parser removed in #9564 converted a! entries in the DEPENDENCIES section into a = <locked version> requirement. Bundler's LockfileParser records the pinned source on the dependency instead and leaves the requirement at >= 0, and Gem::RequestSet#load_lockfile ignores the source, so gem install -g could resolve a newer published version instead of the locked GIT or PATH one.

Restoring the assertions the old parser test carried surfaced three more regressions. Bundler::Source::Rubygems stores remotes in reverse of the lockfile order, flipping source priority for GEM sections with multiple remotes. Bundler::Plugin.from_lock raises UnknownSourceError for PLUGIN SOURCE sections unless the plugin is installed, aborting gem install -g where the old parser skipped the section. defined?(previous_root) in the ensure is true even when the assignment never ran, so an early failure could reset Bundler's root to nil.

hsbt and others added 4 commits August 26, 2026 13:56
The parser removed in #9564 turned a `!` entry in the DEPENDENCIES
section into a `= <version>` requirement. Bundler's LockfileParser
records the pinned source on the dependency and leaves the requirement
at `>= 0`, so `gem install -g` could resolve a newer published version
over the locked GIT or PATH one. Keeping the version as each section is
read pins prereleases too, and lets a PATH section pin to the gemspec on
disk the way the old parser did.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Bundler::Source::Rubygems stores remotes in reverse of the lockfile
order, so reading them straight through flipped which remote a spec
downloads from when a GEM section lists more than one.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`defined?(previous_root)` is true even when the assignment never ran, so
a failure before the root was saved reset Bundler's root to nil.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A PLUGIN SOURCE section sends Bundler::Plugin.from_lock looking for the
plugin that handles it, and finding one loads and runs that plugin's
`plugins.rb`. The plugin index is read from the lockfile directory, so a
repository could run code just by being installed from with
`gem install -g`. Nothing here can use a plugin source anyway.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hsbt
hsbt force-pushed the fix/request-set-lockfile-bang-pinning branch 2 times, most recently from 340eb2e to 1b9f1e1 Compare August 26, 2026 22:24
@hsbt
hsbt merged commit b1b65ea into master Aug 27, 2026
212 checks passed
@hsbt
hsbt deleted the fix/request-set-lockfile-bang-pinning branch August 27, 2026 23:37
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.

1 participant