Skip to content

mise.toml parser fails when ruby line contains end-of-line comments #867

@rileychh

Description

@rileychh

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 for Downloading 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

  1. Create a mise.toml with an EOL comment:

    [tools]
    ruby = "3.4"  # For Fastlane and CocoaPods
  2. Use setup-ruby without explicitly specifying ruby-version:

    - uses: ruby/setup-ruby@v1
      with:
        bundler-cache: true
  3. 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

  1. Remove comments from the ruby line in mise.toml
  2. Create a .ruby-version file (checked before mise.toml)
  3. Explicitly specify ruby-version: 'X.Y' in workflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions