Skip to content

Fix bundler version parsing for RubyGems/Bundler 4.x output format - #1172

Merged
tnikolova82 merged 1 commit into
masterfrom
fix-bundler-version-parsing
Oct 1, 2026
Merged

tnikolova82 merged 1 commit into
masterfrom
fix-bundler-version-parsing

Conversation

@tnikolova82

Copy link
Copy Markdown
Contributor

Summary

Fixes a hard staging failure that broke CI on #1171 (the automated rubygems 3.4.19 -> 4.0.22 dependency bump):

**ERROR** Unable to add bundler path to default environment: failed to determine bundler version from output: 4.0.22 (2026-09-30 commit ff2bd50)
Failed to run all supply scripts: exit status 15

Root cause

GetBundlerVersion() (src/ruby/versions/ruby.go) parses the output of bundle version with a regex requiring a literal "Bundler version " prefix:

re := regexp.MustCompile(`Bundler version (\d+\.\d+\.\d+) .*`)

This matches the legacy output format (e.g. "Bundler version 2.7.2 (2025-09-09 commit b463ced1459)"). As of RubyGems/Bundler 4.x, that prefix has been dropped - the command now just prints the bare version number instead (e.g. "4.0.22 (2026-09-30 commit ff2bd50)"). The regex finds zero matches against the new format, so GetBundlerVersion() returns an error, and the whole supply script aborts (exit status 15) - breaking every integration test that needs bundle to resolve its version (4 failures in #1171's CI run: vendor_bundle, custom_gemfile, Offline, MultiBuildpack/.../binary_buildpack).

This is a real, 100%-reproducible functional regression exposed by the version bump - not CI flakiness.

Fix

  • Extracted the parsing logic into a small, directly unit-testable pure function, parseBundlerVersion(output string) (string, error).
  • Made the "Bundler version " prefix optional in the regex ((?:Bundler version )?(\d+\.\d+\.\d+)), so both the legacy and new output formats parse correctly.

Test plan

  • New TestParseBundlerVersion (src/ruby/versions/ruby_internal_test.go) with 5 cases: legacy prefixed format, new unprefixed format (the exact string from the CI failure), a bare version number, unrecognized output, and empty output.
  • go test ./src/ruby/versions/... - all 37 existing Ginkgo specs + 5 new test cases pass.
  • go build ./..., go vet ./... - clean.

Relationship to #1171

This is a prerequisite fix for #1171 (the rubygems bump) to be mergeable - recommend rebasing/re-running #1171's CI once this lands.

Fixes a hard staging failure exposed by #1171 (automated rubygems
3.4.19 -> 4.0.22 bump):

  **ERROR** Unable to add bundler path to default environment: failed
  to determine bundler version from output: 4.0.22 (2026-09-30 commit
  ff2bd50)
  Failed to run all supply scripts: exit status 15

GetBundlerVersion() parsed `bundle version`'s output with a regex
requiring a literal "Bundler version " prefix (e.g. "Bundler version
2.7.2 (2025-09-09 commit b463ced1459)"). As of RubyGems/Bundler 4.x,
that prefix has been dropped - the command now just prints the bare
version number instead (e.g. "4.0.22 (2026-09-30 commit ff2bd50)"),
causing the regex to find zero matches and the whole supply script to
abort.

Extracted the parsing logic into a small, directly unit-testable pure
function (parseBundlerVersion) and made the "Bundler version " prefix
optional in the regex, so both the legacy and the new output formats
parse correctly.
@tnikolova82
tnikolova82 merged commit 2533b35 into master Oct 1, 2026
7 checks passed
@tnikolova82
tnikolova82 deleted the fix-bundler-version-parsing branch October 1, 2026 14:03
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