Skip to content

fix(ruby): reject non-MRI Ruby engines on Windows with clear error#8539

Merged
jdx merged 1 commit intomainfrom
fix/ruby-windows-non-mri-error
Mar 9, 2026
Merged

fix(ruby): reject non-MRI Ruby engines on Windows with clear error#8539
jdx merged 1 commit intomainfrom
fix/ruby-windows-non-mri-error

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Mar 9, 2026

Summary

  • On Windows, the Ruby plugin uses RubyInstaller2 which only distributes standard MRI Ruby
  • When a user requests a non-MRI engine (jruby, truffleruby, etc.), the plugin would construct an invalid download URL and fail with a confusing 404 error
  • Now fails early with a clear error message explaining that only MRI Ruby is supported on Windows

Fixes #8537

Test plan

  • Verify mise use ruby@jruby-9 on Windows now shows a clear error instead of a 404
  • Verify standard MRI Ruby versions still install correctly on Windows

🤖 Generated with Claude Code


Note

Low Risk
Small, localized change to Windows Ruby installation flow that only adds an upfront validation and error message; minimal impact on successful MRI installs.

Overview
Adds an early Windows-only guard in the Ruby installer to reject non-MRI engine version strings (e.g., JRuby/TruffleRuby) before attempting a RubyInstaller2 download.

This replaces a confusing downstream 404 from a constructed RubyInstaller2 URL with a clear bail! error message explaining that only standard MRI Ruby is supported on Windows.

Written by Cursor Bugbot for commit a1c623b. This will update automatically on new commits. Configure here.

On Windows, the Ruby plugin uses RubyInstaller2 which only distributes
standard MRI Ruby. When a user requests a non-MRI engine like jruby or
truffleruby, the plugin would construct an invalid download URL and fail
with a confusing 404 error. Now it fails early with a clear message.

Fixes #8537

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the Ruby plugin's behavior on Windows by introducing a validation step during installation. Previously, attempting to install non-MRI Ruby engines like JRuby or TruffleRuby on Windows would lead to a cryptic 404 error due to an invalid download URL. The change now proactively checks the requested Ruby engine and, if it's not a standard MRI version, it immediately fails with a user-friendly error message, clarifying that only MRI Ruby is supported on Windows via RubyInstaller2.

Highlights

  • Error Handling: Implemented an early exit mechanism for unsupported Ruby engines on Windows, preventing confusing 404 errors during installation.
  • Platform Specificity: Ensured that only standard MRI Ruby versions are supported and installable on Windows, aligning with RubyInstaller2's distribution.
  • User Experience: Provided a clear and informative error message when a user attempts to install a non-MRI Ruby engine on Windows.
Changelog
  • src/plugins/core/ruby_windows.rs
    • Added a check to prevent installation of non-MRI Ruby engines on Windows.
    • Introduced an early exit with a descriptive error message for unsupported Ruby engines.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 9, 2026

Greptile Summary

This PR adds a focused early-exit guard in the Windows Ruby plugin (ruby_windows.rs) that rejects non-MRI Ruby engines (jruby, truffleruby, etc.) with a human-readable error message before any network I/O is attempted. Previously, the plugin would construct an invalid RubyInstaller2 download URL and fail with a confusing 404.

Key changes:

  • Added bail! at the top of install_version_ that checks ruby_common::is_mri_version(&tv.version) and surfaces a clear error explaining that only MRI Ruby is supported on Windows via RubyInstaller2.
  • Updated the eyre import to include bail.
  • The is_mri_version helper (in the unchanged ruby_common.rs) uses a simple first-character digit check, which correctly distinguishes 3.2.0 (MRI) from jruby-9.4.0.0 (non-MRI).

Minor concerns:

  • No unit test covers the new rejection path in install_version_.
  • The pre-existing test_list_versions_matching test asserts that TruffleRuby versions are retrievable from the Windows backend, which may be misleading now that installing such versions produces an immediate error.
  • resolve_rubyinstaller_lock_info in ruby_common.rs (unchanged) silently returns an empty PlatformInfo for non-MRI versions rather than an error — a mild inconsistency with the new install_version_ behaviour.

Confidence Score: 4/5

  • This PR is safe to merge — the change is minimal, correct, and improves UX; no regressions to the happy path.
  • The fix is a single-function early guard using a well-defined helper (is_mri_version) that already exists. MRI version detection is straightforward (digit-prefix check), the error message is clear, and the change does not touch the download, checksum, or install logic for valid MRI versions. Minor gaps (missing test, potentially misleading existing test assertions) prevent a perfect score.
  • The existing test_list_versions_matching assertions for TruffleRuby in ruby_windows.rs deserve a second look to confirm they still reflect the intended behaviour after this change.

Important Files Changed

Filename Overview
src/plugins/core/ruby_windows.rs Adds an early bail in install_version_ to reject non-MRI Ruby engines with a clear error message; logic is correct and the is_mri_version helper is well-defined. Minor: no new test for the rejection path, and existing TruffleRuby listing assertions may now be misleading.
src/plugins/core/ruby_common.rs Pre-existing file (unchanged by this PR) providing is_mri_version, rubyinstaller_url, and resolve_rubyinstaller_lock_info. Note that resolve_rubyinstaller_lock_info silently returns PlatformInfo::default() for non-MRI versions (no error), creating a mild inconsistency with the new bail in install_version_.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["install_version_ called\n(ruby_windows.rs)"] --> B{"is_mri_version\n(tv.version)?"}
    B -- "No\n(e.g. jruby-9, truffleruby-23)" --> C["bail! with clear error\n'Ruby engine X is not supported\non Windows'"]
    B -- "Yes\n(e.g. 3.2.0, 3.3.1)" --> D["download RubyInstaller2 .7z\n(rubyinstaller_url)"]
    D --> E["verify_checksum"]
    E --> F["install (un7z + rename)"]
    F --> G["verify (ruby -v)"]
    G --> H["install_rubygems_hook"]
    H --> I["test_gem (gem -v)"]
    I --> J["install_default_gems"]
    J --> K["Ok(tv)"]
    C --> L["Err returned to caller"]
Loading

Comments Outside Diff (1)

  1. src/plugins/core/ruby_windows.rs, line 286-313 (link)

    Existing test may be misleading after this change

    The test_list_versions_matching test asserts that TruffleRuby version strings (e.g. truffleruby-24) return non-empty results on the Windows backend. However, _list_remote_versions only fetches from oneclick/rubyinstaller2, whose release tags match RubyInstaller-([0-9.]+)-.* — so only MRI versions are ever listed from that source. After this PR, users on Windows can potentially be shown TruffleRuby versions (from a fallback source) but will immediately hit the bail error when trying to install them.

    If the Windows backend is intended to list only MRI Ruby versions, the TruffleRuby assertions in this test are misleading and should either be removed or converted to negative assertions (is_empty()). Conversely, if TruffleRuby versions are intentionally still shown in the listing for discoverability, a comment explaining this UX decision would help future readers.

    Fix in Claude Code

Fix All in Claude Code

Last reviewed commit: a1c623b

Comment on lines +208 to +214
if !super::ruby_common::is_mri_version(&tv.version) {
bail!(
"Ruby engine '{}' is not supported on Windows.\n\
Only standard MRI Ruby versions can be installed via RubyInstaller2.",
tv.version
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No unit test for the new rejection behavior

There is no test that verifies a non-MRI version string (e.g. jruby-9.4.0.0, truffleruby-23) produces the expected bail error. Consider adding a small unit test for install_version_ that mocks a non-MRI ToolVersion and asserts the error message contains "is not supported on Windows". This would guard against regressions to the early-exit path and make the intent explicit.

Fix in Claude Code

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly adds a check to prevent installation of non-MRI Ruby engines on Windows, providing a much clearer error message to the user. My only feedback is a minor formatting issue in the new error message string which would cause unintended indentation in the output.

Note: Security Review did not run due to the size of the PR.

Comment on lines +210 to +211
"Ruby engine '{}' is not supported on Windows.\n\
Only standard MRI Ruby versions can be installed via RubyInstaller2.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The indentation on the second line of this multi-line string literal will be included in the error message, which is likely not intended. This will cause the second line of the error message to be indented with several spaces. It's better to put the string on a single line or remove the indentation on the continued line to fix the output format.

                "Ruby engine '{}' is not supported on Windows.\nOnly standard MRI Ruby versions can be installed via RubyInstaller2.",

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.3.5 x -- echo 26.0 ± 0.6 25.1 32.4 1.00
mise x -- echo 26.4 ± 1.0 25.7 36.8 1.02 ± 0.05

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.3.5 env 25.7 ± 1.2 24.6 36.9 1.00
mise env 26.2 ± 1.8 25.0 39.4 1.02 ± 0.09

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.3.5 hook-env 26.5 ± 0.9 25.6 34.4 1.00
mise hook-env 27.8 ± 2.7 25.7 52.0 1.05 ± 0.11

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.3.5 ls 25.6 ± 0.9 24.7 33.4 1.00 ± 0.04
mise ls 25.5 ± 0.4 24.9 30.8 1.00

xtasks/test/perf

Command mise-2026.3.5 mise Variance
install (cached) 161ms 161ms +0%
ls (cached) 88ms 87ms +1%
bin-paths (cached) 91ms 90ms +1%
task-ls (cached) 846ms 817ms +3%

@jdx jdx merged commit 4d901a7 into main Mar 9, 2026
38 checks passed
@jdx jdx deleted the fix/ruby-windows-non-mri-error branch March 9, 2026 17:06
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.

1 participant