fix(en): preserve env profile in activated subshells#10124
Conversation
There was a problem hiding this comment.
Code Review
This pull request ensures that explicit -E profiles remain active when a child shell sources mise activate by excluding MISE_ENV from the computed environment diff, and adds an integration test to verify this behavior. The review feedback suggests optimizing this change by temporarily removing and restoring MISE_ENV on the original environment map to avoid an expensive clone, while also explicitly excluding __MISE_DIFF to prevent recursive nesting.
Greptile SummaryFixes
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to the __MISE_DIFF serialization step, with no auth or data-path changes. The fix correctly excludes MISE_ENV from __MISE_DIFF while keeping it in the child process's environment, and the secondary __MISE_DIFF removal avoids stale values reaching the subprocess when serialization fails. The regression test covers the reported scenario end-to-end. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "fix(en): preserve env profile in activat..." | Re-trigger Greptile |
608df90 to
44a5fb1
Compare
44a5fb1 to
22f82fc
Compare
|
Updated in 22f82fc to remove the zsh availability guard; this test now assumes zsh is available in the e2e environment. This comment was generated by an AI coding assistant. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 22f82fc. Configure here.
| eval "\$(mise activate zsh)" | ||
| EOF | ||
| assert_contains "ZDOTDIR=$(pwd)/zsh-home HOME=$(pwd)/zsh-home SHELL=$zsh_bin mise -E dev en -s 'zsh -i -c \"echo \$MISE_ENV\"'" "dev" | ||
| assert_contains "ZDOTDIR=$(pwd)/zsh-home HOME=$(pwd)/zsh-home SHELL=$zsh_bin mise -E dev en -s 'zsh -i -c \"mise env | grep TTT_ENV_NAME\"'" "TTT_ENV_NAME=dev" |
There was a problem hiding this comment.
Missing guard skips zsh tests when zsh unavailable
Medium Severity
Test 17 captures zsh_bin=$(command -v zsh) but never conditionally skips the zsh-specific assertions when zsh is not installed. The test runner executes bash scripts with -euo pipefail (see e2e/run_test line 151), so command -v zsh returning exit code 1 will abort the entire test script immediately. This causes all preceding passing tests (1–16) to also appear as failures on any system without zsh.
Reviewed by Cursor Bugbot for commit 22f82fc. Configure here.
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.5.15 x -- echo |
19.8 ± 0.9 | 17.9 | 25.0 | 1.00 |
mise x -- echo |
20.6 ± 1.4 | 18.4 | 27.3 | 1.04 ± 0.09 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.5.15 env |
19.7 ± 1.3 | 17.2 | 27.5 | 1.00 |
mise env |
19.9 ± 1.0 | 18.2 | 24.8 | 1.01 ± 0.08 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.5.15 hook-env |
20.7 ± 0.9 | 18.9 | 24.2 | 1.00 |
mise hook-env |
21.0 ± 1.1 | 18.7 | 25.7 | 1.01 ± 0.07 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.5.15 ls |
17.0 ± 0.9 | 15.1 | 21.7 | 1.00 |
mise ls |
17.1 ± 0.9 | 15.5 | 22.1 | 1.01 ± 0.08 |
xtasks/test/perf
| Command | mise-2026.5.15 | mise | Variance |
|---|---|---|---|
| install (cached) | 139ms | 141ms | -1% |
| ls (cached) | 67ms | 68ms | -1% |
| bin-paths (cached) | 69ms | 69ms | +0% |
| task-ls (cached) | 140ms | 139ms | +0% |


Summary
-E/MISE_ENVprofiles out of the__MISE_DIFFthat activated child shells reversemise -E dev enspawning interactive zsh that sourcesmise activate zshTest
mise run test:e2e e2e/cli/test_en_mise_envcargo fmt --all -- --checkFixes discussion #10007.
This PR was generated by an AI coding assistant.
Note
Low Risk
Small, targeted change to exec env serialization plus an e2e regression; no auth or data-path changes.
Overview
Fixes
mise -E/MISE_ENVprofiles being dropped when a child frommise en(or exec) runs an interactive shell that sourcesmise activate.When building
__MISE_DIFFfor the spawned process,MISE_ENVis temporarily removed (and any stale__MISE_DIFFcleared) so the serialized diff only captures tool/path changes—not the explicit env profile, which would otherwise be undone on activation.MISE_ENVis restored in the child environment after serialization.Adds e2e test 17: interactive zsh with
mise activatestill seesMISE_ENV=devand dev-specific config aftermise -E dev en.Reviewed by Cursor Bugbot for commit 22f82fc. Bugbot is set up for automated code reviews on this repo. Configure here.