Skip to content

Keep mirror settings readable by Bundler 4.0 - #10075

Merged
hsbt merged 1 commit into
ruby:masterfrom
top-sigrid:pw/yaml-readable-by-bundler-4.0
Nov 18, 2026
Merged

hsbt merged 1 commit into
ruby:masterfrom
top-sigrid:pw/yaml-readable-by-bundler-4.0

Conversation

@top-sigrid

@top-sigrid top-sigrid commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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

Bundler 4.1 writes .bundle/config with the full Gem::YAMLSerializer, which quotes every key containing :. Bundler 4.0 reads the config with the minimal serializer of RubyGems 3.5 to 4.0, which keeps those quotes as part of the key. So Bundler 4.0 silently ignores a mirror that Bundler 4.1 configured.

Projects locked to different Bundler versions share the global config, because Bundler switches to the version in BUNDLED WITH.

Fixes #10073 together with #10076 and #10077, which fix the plugin index part on the read side.

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

A : in a key no longer forces quotes when the key starts with a letter and no : in it is followed by a space or ends it. Psych leaves keys like these unquoted too, and they can't be read as anything but the same string. Every other key with : keeps its quotes, for example 1:20 or 2001-12-14 21:59:43, which Psych would read as a number and a time. Values keep their quotes too, since the minimal serializer strips those. This also applies to other files RubyGems writes, so hosts in ~/.gem/credentials are now written unquoted, as Psych writes them.

A config that Bundler 4.1.0 has already written keeps its format until a Bundler with this change writes it again, e.g. on the next bundle config set.

I checked it end to end on Ruby 4.0.9 with a bundler gem built from this branch, using the reproduction from #10073:

  • Bundler 4.0.20 finds the mirrors this branch wrote, with and without a port in the URL.
  • A config written by Bundler 4.1.0 is read correctly by Bundler 4.0.20 once this branch has written it again.

The RubyGems tests pass, and the YAML tests also with RUBYGEMS_USE_PSYCH=true. The related Bundler specs (settings, mirrors, bundle config, fetcher, compact index and dependency API installs) pass with RGV=. and RGV=system.

Make sure the following tasks are checked

@hsbt

hsbt commented Nov 17, 2026

Copy link
Copy Markdown
Member

Thanks for the detailed report. I've fixed the plugin index on the read side in #10076 and #10077, so could you drop 89149df and keep only the mirror change here? With a gemrc on RubyGems < 4.1, the minimal serializer replaces Bundler's copy and dumps nil as commands: "", which released versions of Bundler can't read either.

@hsbt hsbt added bundler: bug fix skip old stable Leave out of releases on the old stable line labels Nov 17, 2026
@top-sigrid
top-sigrid force-pushed the pw/yaml-readable-by-bundler-4.0 branch from 89149df to 302be3f Compare November 17, 2026 09:03
@top-sigrid top-sigrid changed the title Keep files written by Bundler 4.1 readable by Bundler 4.0 Keep mirror settings readable by Bundler 4.0 Nov 17, 2026
@top-sigrid

Copy link
Copy Markdown
Contributor Author

Thanks for looking into this so quickly. I dropped 89149df so this PR only has the mirror change now. Title and description are updated.

Good point with the gemrc case, locally i had only checked without a gemrc.

@hsbt
hsbt merged commit bd0f392 into ruby:master Nov 18, 2026
114 checks passed
@hsbt

hsbt commented Nov 18, 2026

Copy link
Copy Markdown
Member

Thanks for the quick update! I'll ship this in 4.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bundler: bug fix skip old stable Leave out of releases on the old stable line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bundler 4.1 writes config and plugin index files that Bundler 4.0 misreads

2 participants