KEMBAR78
[Fixes #716] deal with multiple versions in .tool-versions by jtannas · Pull Request #717 · ruby/setup-ruby · GitHub
Skip to content

Conversation

@jtannas
Copy link
Contributor

@jtannas jtannas commented Mar 4, 2025

See #716 for explanation

Tested on one of my projects: https://github.com/jtannas/katachi/actions/runs/13660430691/job/38190080032?pr=19

While it might be cool for it to attempt each ruby version in order (aka. mimic ASDF parsing) or to treat multiple .tool-versions entries as a matrix, that's way beyond what I need and am comfortable tackling as a first PR.

@jtannas jtannas force-pushed the issue-716-multiple-tool-versions branch from 7bd137f to e6e23c7 Compare March 4, 2025 18:22
@jtannas jtannas marked this pull request as ready for review March 4, 2025 18:54
const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim()
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1]
rubyVersion = rubyLine.split(/\s/)[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rubyVersion = rubyLine.split(/\s/)[1]
rubyVersion = rubyLine.match(/^ruby\s+(\S+)/)[1]

would be another way but what you did seems fine too

@eregon eregon merged commit 277ba2a into ruby:master Mar 5, 2025
1 check passed
@eregon
Copy link
Member

eregon commented Mar 5, 2025

While it might be cool for it to attempt each ruby version in order (aka. mimic ASDF parsing)

I agree, that doesn't seem worth the complexity, at least not without a good use case.

or to treat multiple .tool-versions entries as a matrix, that's way beyond what I need and am comfortable tackling as a first PR.

Regarding treating as a matrix that's impossible, AFAIK an action cannot influence the matrix (at least in the same job).

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.

Support .tool-versions files with multiple versions

2 participants