Skip to content

Conversation

@hituzi-no-sippo
Copy link
Contributor

@hituzi-no-sippo hituzi-no-sippo commented Dec 11, 2025

What was the end-user or developer problem that led to this PR?

mise.toml supports specifying Ruby versions using both double quotes (ruby = "3.2.2") and single quotes (ruby = '3.2.2'). However, Bundler's ruby file: directive only recognized double-quoted versions, causing single-quoted versions to fail parsing.

$ bundle --version
4.0.1
$ cat Gemfile
# frozen_string_literal: true

ruby file: 'mise.toml'
$ cat << 'TOML' > mise.toml
[tools]
ruby = "3.4.7"
TOML
$ bundle --version
4.0.1
$ cat Gemfile
# frozen_string_literal: true

ruby file: 'mise.toml'
$ mise x -- ruby --version
ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [x86_64-linux]
$ cat << 'TOML' > mise.toml
[tools]
ruby = "3.4.7"
TOML
$ bundle install
The Gemfile specifies no dependencies
Resolving dependencies...
Bundle complete! 0 Gemfile dependencies, 1 gem now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
$ cat << 'TOML' > mise.toml
[tools]
ruby = '3.4.7'
TOML
$ mise x -- ruby --version
ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [x86_64-linux]
$ bundle install

[!] There was an error parsing `Gemfile`: '3.4.7' is not a valid requirement on the Ruby version. Bundler cannot continue.

 #  from /home/dell-08/workspaces/mise/Gemfile:3
 #  -------------------------------------------
 #  
 >  ruby file: 'mise.toml'
 #  -------------------------------------------

What is your fix for the problem, implemented in this PR?

Updated the regular expression to accept both single quotes (') and double quotes (") when parsing Ruby version files in mise format.

Make sure the following tasks are checked

@hituzi-no-sippo hituzi-no-sippo marked this pull request as ready for review December 11, 2025 11:04
[^\s#"']+ # One or more chars that aren't spaces, #, or quotes
) # End capturing group
"? # Optional closing quote
["']? # Optional closing quote
Copy link
Member

Choose a reason for hiding this comment

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

Can we reject "3.2.2' (quote mismatch)?

The previous regex didn't properly match quoted strings
it would capture the opening quote as part of the version
if quotes were mismatched.
This change properly parses double-quoted, single-quoted,
and unquoted version strings separately.
end

it "raises an error" do
expect { subject }.to raise_error(Bundler::InvalidArgumentError, "= is not a valid requirement on the Ruby version")
Copy link
Contributor Author

@hituzi-no-sippo hituzi-no-sippo Dec 13, 2025

Choose a reason for hiding this comment

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

I'm not sure if the error message = is not a valid requirement ... is appropriate.

If I add = to ([^\s#"']+) # Unquoted version to make it ([^\s#"'=]+), the error message would become [tools]\nruby = \"2.0.0' is not a valid requirement ..., which I feel is better than = is not a valid requirement.
However, I'm concerned this change to ([^\s#"'=]+) might introduce regressions.

Copy link
Member

Choose a reason for hiding this comment

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

Let's not make any changes involving = at this time, as we don't yet fully support the mise format.

FYI: #8998

@hsbt hsbt merged commit 6b618d9 into ruby:master Dec 16, 2025
81 checks passed
@hituzi-no-sippo hituzi-no-sippo deleted the support-single-quotes-mise-format branch December 16, 2025 03:57
hsbt added a commit that referenced this pull request Dec 16, 2025
…ise-format

Support single quotes in mise format ruby version

(cherry picked from commit 6b618d9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants