Skip to content

fix(shell): support hyphenated tool names - #10961

Merged
jdx merged 2 commits into
jdx:mainfrom
risu729:codex-20260713-050101-f605d4
Jul 15, 2026
Merged

jdx merged 2 commits into
jdx:mainfrom
risu729:codex-20260713-050101-f605d4

Conversation

@risu729

@risu729 risu729 commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • centralize encoding and decoding of MISE__VERSION session variables
  • decode variable-name underscores as kebab-case separators so hyphenated tools reactivate correctly
  • use the shared codec in both toolset builders and mise shell set/unset
  • add unit coverage for the ls-lint mapping and an end-to-end shell-hook test with a hyphenated plugin

Root cause

mise shell encoded hyphenated names with shouty snake case, so ls-lint became MISE_LS_LINT_VERSION. Both environment-loading paths decoded the fragment by lowercasing it, reconstructing ls_lint instead of ls-lint. The duplicated decoding logic also allowed those paths to drift.

The mapping intentionally treats hyphens and underscores as equivalent because shell variable names cannot distinguish them. The canonical decoded tool name is kebab-case.

Impact

A tool such as ls-lint installed through mise shell remains active after the next hook-env refresh, repeated mise shell calls succeed, and mise shell --unset removes the matching session selection.

Addresses #7240

Validation

  • cargo test tool_env_var
  • mise run test:e2e cli/test_hook_env
  • mise run lint-fix

Summary by CodeRabbit

  • Bug Fixes
    • Improved tool version environment handling so hyphenated and underscored tool names resolve consistently.
    • Tool version values now load correctly from environment variables, including edge cases around reserved installer/tool version keys.
    • Unsetting a tool configuration now reliably removes the matching version environment variable.
  • Tests
    • Added e2e coverage for plugin installation/version reporting and current listings, plus verification of environment cleanup.
    • Added/updated unit tests for correct env var name round-tripping and reserved-key behavior.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change centralizes tool version environment-variable naming and decoding, applies the helpers to shell setup and runtime loading, re-exports the new APIs, updates hook variables to shared constants, and adds unit and end-to-end coverage for hyphenated tool names.

Changes

Tool environment variable handling

Layer / File(s) Summary
Environment variable helpers
src/env.rs, src/toolset/tool_request_set.rs, src/toolset/mod.rs
Defines shared reserved-variable constants, adds normalized construction and decoding helpers, updates environment scanning, re-exports the APIs, and tests round-trip and reserved-variable behavior.
Runtime environment loading
src/toolset/builder.rs
Uses the shared decoder to convert matching environment variables into environment-sourced tool requests.
Shell and hook integration
src/cli/shell.rs, src/backend/asdf.rs, src/backend/mod.rs
Uses shared names for shell setup and unsetting, installer script variables, and postinstall hook variables.
End-to-end hyphenated tool validation
e2e/cli/test_hook_env
Installs and activates hyphen-tool, verifies its version and current listing, then confirms its environment variable is removed when unset.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant E2ECLI
  participant ShellCLI
  participant ToolsetBuilder
  participant ToolEnvHelpers
  E2ECLI->>ShellCLI: install and activate hyphen-tool
  ShellCLI->>ToolEnvHelpers: construct tool environment variable name
  ToolEnvHelpers-->>ShellCLI: MISE_HYPHEN_TOOL_VERSION
  ShellCLI->>ToolsetBuilder: load shell environment
  ToolsetBuilder->>ToolEnvHelpers: decode tool environment variable
  ToolEnvHelpers-->>ToolsetBuilder: hyphen-tool
  ToolsetBuilder-->>E2ECLI: load environment-sourced tool request
  E2ECLI->>ShellCLI: unset hyphen-tool
  ShellCLI-->>E2ECLI: clear MISE_HYPHEN_TOOL_VERSION
Loading

Possibly related PRs

  • jdx/mise#10415: Updates the same postinstall hook environment and tool-version setup flow.

Poem

I’m a bunny with a tool-env key,
Hyphens hop where underscores be.
Set, decode, unset with cheer,
The right version now appears.
Boing! Tests confirm it’s clear.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: shell support for hyphenated tool names.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes mise shell for tools with hyphenated names (e.g. ls-lint) by centralizing env-var encoding/decoding into two new helpers: tool_env_var_name (encode, using to_shouty_snake_case) and tool_from_env_var_name (decode, using to_kebab_case). Previously the decode path used to_lowercase(), so MISE_LS_LINT_VERSION reconstructed the tool name as ls_lint instead of ls-lint, causing hook-env to miss the session selection on every shell refresh.

  • Core fix (tool_request_set.rs): tool_from_env_var_name decodes LS_LINT → ls-lint via to_kebab_case, making the encode/decode pair a proper round-trip.
  • Consistency (shell.rs, builder.rs): both the set/unset CLI path and the env-loading path now call the same shared codec.
  • E2E test (test_hook_env): symlinks the dummy plugin as hyphen-tool, verifies the exported variable, triggers hook-env via pushd/popd, and confirms --unset clears the variable.

Confidence Score: 5/5

Safe to merge — targeted bug fix with a correct round-trip codec, no existing callers broken, both unit and e2e tests validate the new behavior.

The encode/decode pair is a proper round-trip for hyphenated and aliased tool names. MISE_VERSION exclusion is handled correctly via strip_suffix. The centralization removes the divergent code paths that caused the original bug.

No files require special attention.

Important Files Changed

Filename Overview
src/toolset/tool_request_set.rs Adds tool_env_var_name and tool_from_env_var_name codec helpers; decoding now uses to_kebab_case() so LS_LINT decodes to ls-lint. Unit test covers the round-trip and alias lookup.
src/cli/shell.rs Replaces inline heck::ToShoutySnakeCase formatting with the centralized tool_env_var_name in both set and unset paths.
src/toolset/builder.rs Replaces duplicated env-var parsing logic with a single call to tool_from_env_var_name, eliminating the drift that caused the original bug.
src/env.rs Adds MISE_INSTALL_VERSION_ENV_VAR, MISE_TOOL_VERSION_ENV_VAR, and NON_TOOL_VERSION_ENV_VARS constants as a single source of truth.
e2e/cli/test_hook_env New e2e block validates hyphen-tool install, shell set, hook-env reactivation, and --unset cleanup.

Reviews (2): Last reviewed commit: "refactor(env): centralize internal versi..." | Re-trigger Greptile

@risu729
risu729 marked this pull request as ready for review July 13, 2026 06:06
@jdx
jdx merged commit eb758dd into jdx:main Jul 15, 2026
33 checks passed
@risu729
risu729 deleted the codex-20260713-050101-f605d4 branch July 16, 2026 03:55
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.

2 participants