-
-
Notifications
You must be signed in to change notification settings - Fork 769
fix(activate): reset PATH when activate is called multiple times #6829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(activate): reset PATH when activate is called multiple times #6829
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements PATH reset functionality for multiple mise activations, preventing PATH corruption when mise activate is called multiple times in shell configuration files. The change ensures that subsequent activations reset PATH to the original state before applying mise modifications.
Key Changes:
- Adds conditional logic to check for existing
__MISE_ORIG_PATHvariable across all supported shells - Resets PATH to original state on subsequent activations instead of stacking modifications
- Preserves original PATH value for future resets
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shell/bash.rs | Adds PATH reset logic using bash conditional syntax |
| src/shell/fish.rs | Adds PATH reset logic using fish shell conditional syntax |
| src/shell/zsh.rs | Adds PATH reset logic using zsh conditional syntax |
| src/shell/pwsh.rs | Adds PATH reset logic using PowerShell conditional syntax |
| src/shell/snapshots/*.snap | Updates test snapshots to reflect new activation behavior |
| e2e/cli/test_activate_multiple | Adds end-to-end test for multiple activation scenario |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export __MISE_ORIG_PATH="$PATH" | ||
| export __MISE_ZSH_PRECMD_RUN=0 | ||
| if [ -z "${{__MISE_ORIG_PATH:-}}" ]; then |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double curly braces in variable expansion will be interpreted literally by the shell. Should use single curly braces: ${__MISE_ORIG_PATH:-}
| if [ -z "${{__MISE_ORIG_PATH:-}}" ]; then | |
| if [ -z "${__MISE_ORIG_PATH:-}" ]; then |
| export MISE_SHELL=bash | ||
| export __MISE_ORIG_PATH="$PATH" | ||
| if [ -z "${{__MISE_ORIG_PATH:-}}" ]; then |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double curly braces in variable expansion will be interpreted literally by the shell. Should use single curly braces: ${__MISE_ORIG_PATH:-}
ce13425 to
3e818ac
Compare
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.10.21 x -- echo |
19.4 ± 0.6 | 18.7 | 27.8 | 1.00 |
mise x -- echo |
19.8 ± 0.5 | 18.9 | 26.0 | 1.02 ± 0.04 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.10.21 env |
18.6 ± 0.4 | 17.9 | 22.8 | 1.00 |
mise env |
19.0 ± 0.9 | 18.1 | 29.7 | 1.02 ± 0.05 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.10.21 hook-env |
18.8 ± 0.3 | 18.0 | 20.3 | 1.00 |
mise hook-env |
19.2 ± 0.4 | 18.3 | 20.4 | 1.02 ± 0.03 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.10.21 ls |
16.5 ± 0.5 | 15.7 | 23.4 | 1.00 |
mise ls |
17.1 ± 0.6 | 16.1 | 25.4 | 1.03 ± 0.05 |
xtasks/test/perf
| Command | mise-2025.10.21 | mise | Variance |
|---|---|---|---|
| install (cached) | 110ms | 111ms | +0% |
| ls (cached) | 67ms | 67ms | +0% |
| bin-paths (cached) | 72ms | 76ms | -5% |
| task-ls (cached) | 436ms | 487ms | -10% |
745cc24 to
33484d0
Compare
When mise activate is called multiple times in a shell rc file, the second call now resets PATH to the original state before applying mise modifications. This prevents PATH corruption when users have multiple activate calls in their shell configuration, ensuring each activation behaves as if it's the first. Changes: - bash: Check if __MISE_ORIG_PATH exists, reset PATH if it does - fish: Check if __MISE_ORIG_PATH exists, reset PATH if it does - zsh: Check if __MISE_ORIG_PATH exists, reset PATH if it does - pwsh: Check if __MISE_ORIG_PATH exists, reset PATH if it does - Added E2E test for multiple activate calls The feature ensures that calling activate a second time will: 1. Reset PATH to __MISE_ORIG_PATH (the original PATH from first activation) 2. Apply mise modifications on top of the clean slate 3. Preserve __MISE_ORIG_PATH for potential future activations
33484d0 to
caa7a95
Compare
0149c4b to
54df803
Compare
### 🐛 Bug Fixes - **(activate)** reset PATH when activate is called multiple times by @jdx in [#6829](#6829) - **(env)** preserve user-configured PATH entries from env._.path by @jdx in [#6835](#6835) - store tool options for all backends in metadata by @roele in [#6807](#6807) ### 📚 Documentation - fix usage spec syntax from 'option' to 'flag' by @jdx in [#6834](#6834) ### 📦️ Dependency Updates - update ghcr.io/jdx/mise:alpine docker digest to 7351bbe by @renovate[bot] in [#6826](#6826) - update ghcr.io/jdx/mise:deb docker digest to 3a847f2 by @renovate[bot] in [#6828](#6828) - update ghcr.io/jdx/mise:copr docker digest to 546dffb by @renovate[bot] in [#6827](#6827) - pin jdx/mise-action action to e3d7b8d by @renovate[bot] in [#6825](#6825)
… operations (#6994) - addresses the unexpected behaviour discussed here: #6876 - previously, work was done to have `mise` reverse the changes it made to the environment variables: #6829 - however, for nushell, this resulted in the raw operations CSV text becoming part of the activation script, which is not valid nushell syntax - this PR wraps the raw operations CSV text in quotes to make it a string literal, and then passes it through `| parse env | update-env` just as with other places in the nushell script that make use of the raw operations CSV text - in order for that work, the `parse env` and `update-env` functions were re-ordered to always be above the deactivation statements
Summary
When
mise activateis called multiple times in a shell rc file, each call now resets__MISE_ORIG_PATHto the current PATH. This allows mise tools to move to the front of the "locked in" user path additions.Problem
Previously, when activate was called multiple times:
mise activate→__MISE_ORIG_PATH=A, PATH=mise_tools:AB:mise_tools:Amise activate→__MISE_ORIG_PATHstill=A, PATH=B:mise_tools:A(mise tools stay in place)Result: mise tools didn't move to the front of the original path when activate was called again.
Solution
Now, each activation unconditionally resets
__MISE_ORIG_PATHto the current PATH:mise activate→__MISE_ORIG_PATH=A, PATH=mise_tools:AB:mise_tools:Amise activate→__MISE_ORIG_PATH=B:mise_tools:A, then hook-env runs → PATH=mise_tools:B:AThis "locks in" user additions at each activation point. The most recent custom additions stay at the front, but mise tools move to be immediately after them (and before older additions).
Example Behavior
Result:
custom2:mise_tools:custom1:original_path- newest additions stay front, mise tools move to front of "locked in" path.Changes
__MISE_ORIG_PATH="$PATH"on each activationtest_activate_multipleto verify the behavior🤖 Generated with Claude Code
Note
Repeated activation keeps user-added PATH entries at the front without duplication; deactivation removes mise-managed env/paths while preserving user/pristine entries, with new e2e coverage.
__MISE_ORIG_PATHonly if unset acrossbash,zsh,fish,pwsh,nu,xonsh,elvish.src/cli/deactivate.rs: usebuild_deactivation_script(...)and also unset__MISE_ORIG_PATH.hook_env::build_path_operations: computepreby excluding original and previous mise-managed paths; preserves genuine user additions; filters installs to avoid duplicates.hook_env::clear_old_env+ newcompute_deactivated_path: rebuild PATH on deactivate to drop mise paths while retaining user/pristine entries (special-case fish PATH ops).e2e/cli/test_activate_multipleande2e/cli/test_deactivate.__MISE_ORIG_PATHand deactivation prelude.Written by Cursor Bugbot for commit 54df803. This will update automatically on new commits. Configure here.