Skip to content

fix(installer): normalize current version before comparison#8649

Merged
jdx merged 1 commit intojdx:mainfrom
tak848:fix-installer-current-version
Mar 19, 2026
Merged

fix(installer): normalize current version before comparison#8649
jdx merged 1 commit intojdx:mainfrom
tak848:fix-installer-current-version

Conversation

@tak848
Copy link
Contributor

@tak848 tak848 commented Mar 18, 2026

Summary

  • Normalize the current version before standalone installer comparisons
  • Keep the rendered install.sh format unchanged

Problem

The standalone installer strips the leading v from the selected version before using it:

version="${version#v}"

But MISE_CURRENT_VERSION is rendered from the release tag form and still includes the v prefix.

That means current-version checks never match, so the installer always falls back to the non-current-version path.

In practice, this bypasses:

  • Embedded checksums for the current release
  • The current-release CDN tarball path

Changes

  • Normalize MISE_CURRENT_VERSION into a local current_version in get_checksum()
  • Normalize MISE_CURRENT_VERSION into a local current_version in install_mise()
  • Keep the public install.sh version literal unchanged and only fix the comparisons

This intentionally avoids changing the rendered install.sh format. Both version and current_version undergo the same #v strip; if you'd prefer, I can follow up by renaming both to make the normalized semantics more explicit.

Signed-off-by: tak848 <pairs_char0j@icloud.com>
@gemini-code-assist
Copy link
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 addresses a critical issue in the standalone installer where version comparisons were consistently failing due to a mismatch in how version strings were formatted. By normalizing the MISE_CURRENT_VERSION to remove its 'v' prefix, the installer can now correctly identify the current version, enabling proper utilization of embedded checksums and the current-release CDN tarball path. This ensures the installer behaves as expected for the current release without unintended fallbacks.

Highlights

  • Version Normalization: Normalized the MISE_CURRENT_VERSION variable by stripping its leading 'v' prefix before performing comparisons within the standalone installer script.
  • Installer Logic Fix: Corrected the logic in get_checksum() and install_mise() functions to ensure accurate version comparisons, preventing the installer from always falling back to non-current-version paths.
  • Preserved Format: Maintained the existing format of the rendered install.sh script, ensuring only the internal comparison logic was adjusted without altering public-facing version literals.
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.

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.

@tak848 tak848 marked this pull request as ready for review March 18, 2026 23:01
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR fixes a long-standing bug in the standalone installer where the current-version fast-path (embedded checksums and CDN tarball URL) was never reached because MISE_CURRENT_VERSION carries a v prefix (e.g. v2.10.1) while the installer strips that prefix from the working version variable, making the string comparison always fail.

Key changes:

  • In get_checksum(): adds a local current_version variable that strips the leading v from MISE_CURRENT_VERSION before comparing against the already-stripped version parameter.
  • In install_mise(): same normalisation — current_version is derived by stripping the v prefix from MISE_CURRENT_VERSION, so the version != current_version guard correctly identifies the current-release install path.
  • The public install.sh literal format is intentionally preserved; only the internal comparison variables change.

The fix is minimal, correct, and well-scoped — the ${var#v} parameter expansion is a no-op when the prefix is already absent, so the change is safe regardless of whether MISE_CURRENT_VERSION is emitted with or without the prefix in the future.

Confidence Score: 5/5

  • This PR is safe to merge — it is a targeted, low-risk bug fix with no functional regressions.
  • The change is confined to two small, symmetric patches in a single shell script template. Both patches follow the same well-established POSIX parameter-expansion idiom (${var#v}) already used elsewhere in the script. The logic is easy to verify: the installer already strips the v from version, so stripping it from MISE_CURRENT_VERSION into current_version before comparison is the correct and minimal fix. No new edge cases are introduced.
  • No files require special attention.

Important Files Changed

Filename Overview
packaging/standalone/install.envsubst Adds a local current_version variable (stripped of the v prefix) in both get_checksum() and install_mise() so that the v-stripped version variable is compared against an equally v-stripped copy of MISE_CURRENT_VERSION, fixing comparisons that previously always failed.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["install_mise() called"] --> B["version = MISE_VERSION or MISE_CURRENT_VERSION\nstrip leading v"]
    A --> C["current_version = MISE_CURRENT_VERSION\nstrip leading v  ← NEW"]

    B --> D{"version == current_version\n(both v-stripped)?"}
    C --> D

    D -- "No (different version) OR\nMISE_INSTALL_FROM_GITHUB=1" --> E["tarball_url = GitHub releases URL\nhttps://github.com/.../mise-v{version}-..."]
    D -- "Yes (current version) AND\nMISE_TARBALL_URL set" --> F["tarball_url = MISE_TARBALL_URL"]
    D -- "Yes (current version) AND\nno override" --> G["tarball_url = CDN URL\nhttps://mise.jdx.dev/v{version}/..."]

    E --> H["download_file(tarball_url)"]
    F --> H
    G --> H

    H --> I["get_checksum(version, os, arch, ext)"]
    I --> J["current_version = MISE_CURRENT_VERSION\nstrip leading v  ← NEW"]
    J --> K{"version == current_version?"}
    K -- "Yes" --> L["Use embedded static checksums\n(MISE_CHECKSUM_* vars)"]
    K -- "No" --> M["Fetch SHASUMS256.txt from GitHub releases"]

    L --> N["Validate checksum → extract tarball"]
    M --> N
Loading

Last reviewed commit: "fix(installer): norm..."

Copy link
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 addresses a bug in the standalone installer script where version comparisons would fail due to inconsistent 'v' prefixes. The fix involves normalizing the MISE_CURRENT_VERSION variable before it's used in comparisons within the get_checksum and install_mise functions. My review includes suggestions to make the new code slightly more concise while maintaining correctness.

Comment on lines +113 to +114
current_version="$MISE_CURRENT_VERSION"
current_version="${current_version#v}"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can combine these two lines into a single line. This is a standard POSIX shell feature.

Suggested change
current_version="$MISE_CURRENT_VERSION"
current_version="${current_version#v}"
current_version="${MISE_CURRENT_VERSION#v}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is an envsubst template. $MISE_CURRENT_VERSION is substituted literally before the shell runs, so writing ${MISE_CURRENT_VERSION#v} would be expanded into ${v2026.3.9#v}, which breaks. The two-line form captures the substituted value into a local variable first, then strips the prefix.

Comment on lines +247 to +248
current_version="$MISE_CURRENT_VERSION"
current_version="${current_version#v}"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can combine these two lines into a single line. This is a standard POSIX shell feature.

Suggested change
current_version="$MISE_CURRENT_VERSION"
current_version="${current_version#v}"
current_version="${MISE_CURRENT_VERSION#v}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above — envsubst constraint requires the two-line form.

@tak848
Copy link
Contributor Author

tak848 commented Mar 18, 2026

coverage-7 failure is unrelated to this PR — caused by Java EA version bump (26 → 27). Fix is tracked in #8634

@jdx jdx enabled auto-merge (squash) March 19, 2026 22:45
@jdx jdx disabled auto-merge March 19, 2026 22:46
@jdx jdx merged commit 7da7334 into jdx:main Mar 19, 2026
33 of 35 checks passed
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.

3 participants