Skip to content

Commit bf70bfd

Browse files
committed
Fix bundler version detection for rubygems 4.x
1 parent 601498a commit bf70bfd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/ruby/versions/ruby.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ type output struct {
4747
}
4848

4949
func (v *Versions) GetBundlerVersion() (string, error) {
50+
if v.bundlerVersion != "" {
51+
return v.bundlerVersion, nil
52+
}
53+
54+
// Fallback: run `bundle version` for environments where bundlerVersion
55+
// was not populated from the manifest.
5056
stdout := bytes.NewBuffer(nil)
5157

5258
cmd := exec.Command("bundle", "version")
@@ -58,6 +64,8 @@ func (v *Versions) GetBundlerVersion() (string, error) {
5864
return "", err
5965
}
6066

67+
// rubygems >= 4.x changed `bundle version` output from
68+
// "Bundler version X.Y.Z (...)" to "X.Y.Z (...)".
6169
re := regexp.MustCompile(`(?:Bundler version )?(\d+\.\d+\.\d+) .*`)
6270
match := re.FindStringSubmatch(stdout.String())
6371

0 commit comments

Comments
 (0)