Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(env): force uppercase PATH key on unix#9927

Merged
jdx merged 2 commits into
jdx:mainfrom
risu729:fix/zsh-path-key
May 29, 2026
Merged

fix(env): force uppercase PATH key on unix#9927
jdx merged 2 commits into
jdx:mainfrom
risu729:fix/zsh-path-key

Conversation

@risu729

@risu729 risu729 commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • force mise's internal PATH key to PATH on Unix so zsh activation/hook output cannot use lowercase path
  • keep Windows case-insensitive PATH key detection explicit
  • add regression coverage for lowercase path handling

Addresses discussion #9925.

Tests

  • cargo fmt --check
  • cargo test env::tests::test_path_key_from_env_uses_uppercase_path_on_unix

@greptile-apps

greptile-apps Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a regression where mise would use a lowercase path key on Unix (e.g., from zsh's special path array being exported), causing PATH manipulation to break. The fix splits path_key_from_env by platform: on Unix it unconditionally returns "PATH", and on Windows it keeps the existing case-insensitive lookup with a fallback.

  • Unix path key hardened: PATH_KEY is now always "PATH" on Unix, regardless of what the environment contains, preventing the zsh path-vs-PATH mismatch.
  • Windows behavior preserved: Case-insensitive matching via eq_ignore_ascii_case is retained, matching the Windows convention that env var names are case-insensitive.
  • Tests added: Both platforms have dedicated unit tests covering the new code paths, including the lowercase-input regression case on Unix.

Confidence Score: 5/5

Targeted, well-tested fix with no risk to existing behaviour on either platform.

The change is narrow: a two-branch platform split replaces a single fragile heuristic. The Unix branch ignores its input by design, the Windows branch is functionally identical to the original. Both paths are covered by new unit tests that directly exercise the regression scenario.

No files require special attention.

Important Files Changed

Filename Overview
src/env.rs Replaces the find_or_first-based PATH key detection with a platform-split: always returns "PATH" on Unix, preserves case-insensitive lookup on Windows. Adds corresponding unit tests for both platforms.

Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/zsh-path-ke..." | Re-trigger Greptile

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

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.

Code Review

This pull request refactors the PATH_KEY initialization in src/env.rs to handle platform-specific environment variable casing, specifically ensuring that Windows preserves the original casing of the path variable. It also adds unit tests for both Unix and Windows implementations. Feedback was provided to optimize the environment variable iteration by using vars_os() instead of vars_safe(), which avoids unnecessary string allocations for values and prevents potential issues where the path variable might be skipped due to invalid UTF-8 content.

Comment thread src/env.rs Outdated
@risu729 risu729 force-pushed the fix/zsh-path-key branch from b22c68f to 58d0bc6 Compare May 16, 2026 20:33
@risu729 risu729 marked this pull request as ready for review May 18, 2026 09:55
@jdx jdx merged commit d04c86c into jdx:main May 29, 2026
32 checks passed
@risu729 risu729 deleted the fix/zsh-path-key branch May 29, 2026 14: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