fix(activate): export __MISE_EXE and resolve bare ARGV0 to absolute path#9081
fix(activate): export __MISE_EXE and resolve bare ARGV0 to absolute path#9081
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the bash activation script to export the __MISE_EXE environment variable and refines the logic for resolving the executable path on Linux to prefer absolute paths. A review comment points out that relative paths containing separators, such as ./mise, are not currently transformed into absolute paths, which could cause issues if the working directory is changed after activation. The reviewer provided a code snippet to resolve this by joining such paths with the current working directory.
| let argv0 = PathBuf::from(&*env::ARGV0); | ||
| if argv0.is_absolute() { | ||
| argv0 | ||
| } else { | ||
| which::which(&*env::ARGV0).unwrap_or_else(|_| env::MISE_BIN.clone()) | ||
| } |
There was a problem hiding this comment.
The current implementation correctly resolves bare names (e.g., mise) to absolute paths using which. However, if ARGV0 is a relative path with a separator (e.g., ./mise), which returns it as-is, leaving mise_bin relative. This can cause the mise function to fail if the user changes their current working directory after activation. To ensure __MISE_EXE is always absolute (as expected by the tests and for robustness), relative paths should be joined with the current working directory to make them absolute without resolving symlinks.
let argv0 = PathBuf::from(&*env::ARGV0);
let path = if argv0.is_absolute() {
argv0
} else {
which::which(&*env::ARGV0).unwrap_or_else(|_| env::MISE_BIN.clone())
};
if path.is_absolute() {
path
} else {
std::env::current_dir()
.map(|cwd| cwd.join(path))
.unwrap_or_else(|_| env::MISE_BIN.clone())
}
Greptile SummaryThis PR fixes two related bugs in Confidence Score: 5/5This PR is safe to merge; both fixes are minimal, correct, and well-tested. All findings are P2 or lower (edge cases already acknowledged in prior thread comments). The primary bug fix (export + bare ARGV0 resolution) is straightforward and the unit/e2e test suite passes. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["mise activate bash (Linux)"] --> B{"ARGV0 is absolute?"}
B -- Yes --> E["Use ARGV0 as mise_bin"]
B -- No --> C["which::which(ARGV0)"]
C -- Success --> D{"Result is absolute?"}
C -- Failure --> F["Fallback: MISE_BIN (current_exe)"]
D -- Yes --> E
D -- No --> G["current_dir().join(path)"]
G -- Success --> E
G -- Failure --> F
E --> H["Embed as export __MISE_EXE=<mise_bin> in activate.sh"]
F --> H
H --> I["Child shell inherits __MISE_EXE via export"]
Reviews (2): Last reviewed commit: "fix(activate): resolve relative ARGV0 pa..." | Re-trigger Greptile |
| eval "$(mise activate bash --no-hook-env)" | ||
| assert "bash -c 'echo \$__MISE_EXE'" "$__MISE_EXE" |
There was a problem hiding this comment.
Test assertion 3 uses
eval in test shell scope
eval "$(mise activate bash --no-hook-env)" modifies the current test shell's environment (defines mise(), _mise_hook, etc., and calls _mise_hook immediately). If _mise_hook fails or produces unexpected output, it could affect the assert below it. Consider sourcing into a subshell or just relying on assertions 1 and 2 (which already prove the export is present) to keep the test scope cleaner.
|
Addressed the relative path edge case — |
### 🚀 Features - **(npm)** use --min-release-age for npm 11.10.0+ supply chain protection by @webkaz in [#9072](#9072) - **(registry)** add openfga by @mnm364 in [#9084](#9084) - **(task)** allow to set confirmation default by @roele in [#9089](#9089) - support os/arch compound syntax in tool os filtering by @RobertDeRose in [#9088](#9088) ### 🐛 Bug Fixes - **(activate)** export __MISE_EXE and resolve bare ARGV0 to absolute path by @fru1tworld in [#9081](#9081) - **(install)** support aliased installs sharing a backend by @jdx in [#9093](#9093) - **(shim)** use which_no_shims when resolving mise binary in reshim and doctor by @kevinswiber in [#9071](#9071) - filter empty segments in colon-separated env var parsing by @baby-joel in [#9076](#9076) ### 📚 Documentation - fix wrong file reference to forgejo backend implemenation by @roele in [#9090](#9090) - fix cli token command for token resolution by @roele in [#9077](#9077) ### 📦 Registry - add trzsz-go ([aqua:trzsz/trzsz-go](https://github.com/trzsz/trzsz-go)) by @ZeroAurora in [#9083](#9083) - add copilot ([aqua:github/copilot-cli](https://github.com/github/copilot-cli)) by @risu729 in [#9082](#9082) ### Chore - add AGENTS.md symlink by @jdx in [#9094](#9094) ### New Contributors - @kevinswiber made their first contribution in [#9071](#9071) - @webkaz made their first contribution in [#9072](#9072) - @RobertDeRose made their first contribution in [#9088](#9088) ## 📦 Aqua Registry Updates #### New Packages (7) - [`IBM-Cloud/ibm-cloud-cli-release`](https://github.com/IBM-Cloud/ibm-cloud-cli-release) - [`max-sixty/worktrunk`](https://github.com/max-sixty/worktrunk) - [`micelio.dev/hif`](https://github.com/micelio.dev/hif) - [`pgplex/pgschema`](https://github.com/pgplex/pgschema) - [`rose-pine/rose-pine-bloom`](https://github.com/rose-pine/rose-pine-bloom) - [`santosr2/TerraTidy`](https://github.com/santosr2/TerraTidy) - [`trzsz/trzsz-go`](https://github.com/trzsz/trzsz-go) #### Updated Packages (3) - [`mvdan/sh`](https://github.com/mvdan/sh) - [`rvben/rumdl`](https://github.com/rvben/rumdl) - [`temporalio/temporal`](https://github.com/temporalio/temporal)
## [2026.4.14](https://github.com/jdx/mise/compare/v2026.4.13..v2026.4.14) - 2026-04-15 ### Chore - bump sigstore-verification by @jdx in [#9128](jdx/mise#9128) ## [2026.4.13](https://github.com/jdx/mise/compare/v2026.4.12..v2026.4.13) - 2026-04-15 ### 🐛 Bug Fixes - **(go)** honor install_before for module versions by @mariusvniekerk in [#9097](jdx/mise#9097) - **(vfox-plugin)** support Git URL with commit hash for mise.toml by @Oyami-Srk in [#9099](jdx/mise#9099) - `MISE_FETCH_REMOTE_VERSIONS_CACHE` not respected by @mcncl in [#9096](jdx/mise#9096) ### 📦️ Dependency Updates - unblock cargo-deny advisories check by @jdx in [#9112](jdx/mise#9112) ### New Contributors - @mariusvniekerk made their first contribution in [#9097](jdx/mise#9097) - @mcncl made their first contribution in [#9096](jdx/mise#9096) - @Oyami-Srk made their first contribution in [#9099](jdx/mise#9099) ## [2026.4.12](https://github.com/jdx/mise/compare/v2026.4.11..v2026.4.12) - 2026-04-15 ### 🚀 Features - **(npm)** use --min-release-age for npm 11.10.0+ supply chain protection by @webkaz in [#9072](jdx/mise#9072) - **(registry)** add openfga by @mnm364 in [#9084](jdx/mise#9084) - **(task)** allow to set confirmation default by @roele in [#9089](jdx/mise#9089) - support os/arch compound syntax in tool os filtering by @RobertDeRose in [#9088](jdx/mise#9088) ### 🐛 Bug Fixes - **(activate)** export __MISE_EXE and resolve bare ARGV0 to absolute path by @fru1tworld in [#9081](jdx/mise#9081) - **(install)** support aliased installs sharing a backend by @jdx in [#9093](jdx/mise#9093) - **(shim)** use which_no_shims when resolving mise binary in reshim and doctor by @kevinswiber in [#9071](jdx/mise#9071) - filter empty segments in colon-separated env var parsing by @baby-joel in [#9076](jdx/mise#9076) ### 📚 Documentation - fix wrong file reference to forgejo backend implemenation by @roele in [#9090](jdx/mise#9090) - fix cli token command for token resolution by @roele in [#9077](jdx/mise#9077)
Refs #8984
__MISE_EXEwas not exported in bash activate, so child shells couldn't access it and themisefunction failed. Additionally on Linux, when ARGV0 is a bare name (e.g.mise) instead of an absolute path, PATH changes could break execution.exportto__MISE_EXE=inactivate.shwhich::which, falling back toMISE_BINVerification:
mise run lint-fixmise run test:unit(629 passed)mise run test:e2e test_activate_export