-
-
Notifications
You must be signed in to change notification settings - Fork 360
Description
Ensure the following before filing this issue
-
I verified it reproduces with the latest version with
- uses: ruby/setup-ruby@v1(see Versioning policy) -
I tried to reproduce the issue locally by following the workflow steps (including all commands done by
ruby/setup-ruby, except forDownloading Ruby&Extracting Ruby),
and it did not reproduce locally (if it does reproduce locally, it's not a ruby/setup-ruby issue)
Are you running on a GitHub-hosted runner or a self-hosted runner?
GitHub-hosted runner
Link to the failed workflow job (must be a public workflow job, so the necessary information is available)
https://github.com/rileychh/repros/actions/runs/21517607329/job/61999846713
Any other notes?
setup-ruby crashes when parsing mise.toml if the ruby version line contains an end-of-line comment (which is valid TOML syntax).
Error
TypeError: Cannot read properties of undefined (reading 'match')
at parseRubyEngineAndVersion
Steps to Reproduce
-
Create a
mise.tomlwith an EOL comment:[tools] ruby = "3.4" # For Fastlane and CocoaPods
-
Use setup-ruby without explicitly specifying
ruby-version:- uses: ruby/setup-ruby@v1 with: bundler-cache: true
-
Run the workflow
Expected Behavior
setup-ruby should parse ruby = "3.4" correctly and use version 3.4, ignoring the comment (as per TOML specification where # starts a comment).
Actual Behavior
Action crashes because the regex fails to match the line, resulting in undefined.match() call.
Root Cause
In index.js, the regex for parsing mise.toml anchors to end-of-line:
const regexp = /^ruby\s*=\s*['"](.+)['"]$/This regex requires the line to end immediately after the closing quote:
- Matches:
ruby = "3.4" - No match:
ruby = "3.4" # comment
When no lines match, filter()[0] returns undefined, causing the subsequent .match() call to crash.
Suggested Fix
Update the regex to allow optional trailing content:
const regexp = /^ruby\s*=\s*['"](.+?)['"]/Or more explicitly handle comments:
const regexp = /^ruby\s*=\s*['"](.+)['"]\s*(?:#.*)?$/Workarounds
- Remove comments from the ruby line in
mise.toml - Create a
.ruby-versionfile (checked beforemise.toml) - Explicitly specify
ruby-version: 'X.Y'in workflow