fix(env): add trace logging for module hook PATH diagnostics#8981
Conversation
Add trace-level logging to help diagnose issues where mise-managed tools are not found in cmd.exec() inside MiseEnv Lua hooks (e.g. #8962). - Log PATH passed to mise_env hooks in vfox - Log whether cmd.exec() uses mise-constructed env or inherits process env - Log PATH passed to module directives during env resolution Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Gate PATH trace logs behind log::log_enabled! to avoid formatting the long PATH string when trace is disabled - Promote cmd.exec log to debug! so it shows with MISE_DEBUG=1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryAdds Confidence Score: 5/5Safe to merge — behavior is unchanged; only logging verbosity is affected. All three changes are additive trace/debug logging with no logic changes. The one P2 finding (wrong log level in cmd.rs) is a style nit that doesn't affect correctness or security. crates/vfox/src/lua_mod/cmd.rs —
|
| Filename | Overview |
|---|---|
| crates/vfox/src/lua_mod/cmd.rs | Adds has_mise_env boolean tracking and logs it at debug! level — inconsistent with the PR's stated trace!-only policy; should use trace! instead. |
| crates/vfox/src/vfox.rs | Adds trace!-level PATH logging guarded by log_enabled! before calling set_cmd_env; clean and consistent with the PR's intent. |
| src/config/env_directive/mod.rs | Adds trace!-level PATH logging for module directives, guarded by log_enabled!; both branches correctly use trace!. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["env resolution\n(env_directive/mod.rs)"] -->|"trace: module {name}: PATH=..."| L1["MISE_TRACE log"]
A --> B["Vfox::mise_env\n(vfox.rs)"]
B -->|"trace: [vfox:{sdk}] mise_env PATH=..."| L2["MISE_TRACE log"]
B --> C["plugin.set_cmd_env(env)"]
C --> D["Lua hook executes\ncmd.exec()"]
D -->|"debug: [cmd.exec] command=... has_mise_env=..."| L3["MISE_DEBUG log ⚠️ should be trace"]
D --> E["Command runs with\nmise-constructed env"]
Reviews (2): Last reviewed commit: "fix(env): gate PATH logging on log level..." | Re-trigger Greptile
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 b17e0b3. Configure here.
| } else { | ||
| false | ||
| }; | ||
| debug!("[cmd.exec] command={command:?} has_mise_env={has_mise_env}"); |
There was a problem hiding this comment.
Log level is debug instead of trace
Low Severity
The debug! macro is used on this line, but the PR description explicitly states "All at trace! level — only visible with MISE_TRACE=1, zero cost in normal operation." The other two logging additions in vfox.rs and mod.rs correctly use trace!. Using debug! here means this log line will appear with MISE_DEBUG=1 instead of requiring MISE_TRACE=1, making it noisier than intended and inconsistent with the other additions.
Reviewed by Cursor Bugbot for commit b17e0b3. Configure here.
There was a problem hiding this comment.
Code Review
This pull request introduces diagnostic logging for environment variables, specifically tracking the PATH variable and mise_env status across the vfox and env_directive modules. The feedback suggests changing a debug! log to trace! in src/config/env_directive/mod.rs to ensure consistency with the other newly added diagnostic logs.
| if log::log_enabled!(log::Level::Trace) { | ||
| if let Some(path) = env_map.get(&*env::PATH_KEY) { | ||
| trace!("module {name}: PATH={path}"); | ||
| } else { |
There was a problem hiding this comment.
For consistency with the pull request description stating "All at trace! level", consider using trace! instead of debug! here. While debug! is also a diagnostic log, using trace! would ensure uniform logging levels for PATH diagnostics.
| } else { | |
| trace!("module {name}: no PATH in env_map"); |
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.7 x -- echo |
16.6 ± 0.4 | 15.8 | 18.2 | 1.00 |
mise x -- echo |
17.2 ± 0.6 | 16.4 | 22.8 | 1.04 ± 0.04 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.7 env |
16.4 ± 0.4 | 15.6 | 19.5 | 1.00 |
mise env |
16.8 ± 0.4 | 16.0 | 18.4 | 1.03 ± 0.03 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.7 hook-env |
16.9 ± 0.4 | 15.9 | 18.1 | 1.00 |
mise hook-env |
17.3 ± 0.4 | 16.4 | 18.9 | 1.02 ± 0.03 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.7 ls |
15.4 ± 0.4 | 14.7 | 18.5 | 1.00 |
mise ls |
15.8 ± 0.3 | 15.0 | 17.0 | 1.02 ± 0.03 |
xtasks/test/perf
| Command | mise-2026.4.7 | mise | Variance |
|---|---|---|---|
| install (cached) | 111ms | 111ms | +0% |
| ls (cached) | 63ms | 63ms | +0% |
| bin-paths (cached) | 65ms | 66ms | -1% |
| task-ls (cached) | 691ms | 684ms | +1% |
### 🚀 Features - **(config)** add lockfile_platforms setting to restrict lockfile platforms by @cameronbrill in [#8966](#8966) - **(sandbox)** support wildcard patterns in allow_env by @jdx in [#8974](#8974) - bump usage-lib v2 → v3 to render examples in task --help by @baby-joel in [#8890](#8890) ### 🐛 Bug Fixes - **(activate)** handle empty __MISE_FLAGS array with set -u on bash 3.2 by @jdx in [#8988](#8988) - **(env)** add trace logging for module hook PATH diagnostics by @jdx in [#8981](#8981) - **(go)** Query module proxy directly for version resolution by @c22 in [#8968](#8968) - **(install)** render tera templates in tool postinstall hooks by @jdx in [#8978](#8978) - **(install)** add missing env vars to tool postinstall hooks by @jdx in [#8977](#8977) - **(task)** prevent hang when skipped task has dependents by @jdx in [#8937](#8937) - **(task)** invalidate dependent task sources when dependency runs by @jdx in [#8975](#8975) - **(task)** prevent deadlock when MISE_JOBS=1 with sub-task references by @jdx in [#8976](#8976) - **(task)** fetch remote task files before parsing usage specs by @jdx in [#8979](#8979) - **(task)** prevent panic when running parallel sub-tasks with replacing output by @jdx in [#8986](#8986) - **(upgrade)** update lockfile and config when upgrading to specific version by @jdx in [#8983](#8983) ### 📚 Documentation - **(node)** remove "recommended for teams" from pin example by @jdx in [b334363](b334363) ### 📦️ Dependency Updates - update ghcr.io/jdx/mise:alpine docker digest to 17a29f2 by @renovate[bot] in [#8995](#8995) - update docker/dockerfile:1 docker digest to 2780b5c by @renovate[bot] in [#8994](#8994) ### New Contributors - @baby-joel made their first contribution in [#8890](#8890) - @cameronbrill made their first contribution in [#8966](#8966) - @c22 made their first contribution in [#8968](#8968)


Summary
trace!-level logging to help diagnose tools = true in MiseEnv Lua hooks broken since v2026.4.6 — mise-managed tools not found in cmd.exec() #8962 (and similar issues where mise-managed tools aren't found incmd.exec()inside MiseEnv Lua hooks)mise_envhooks in vfox (crates/vfox/src/vfox.rs)cmd.exec()uses the mise-constructed env or inherits process env (crates/vfox/src/lua_mod/cmd.rs)src/config/env_directive/mod.rs)All at
trace!level — only visible withMISE_TRACE=1, zero cost in normal operation.Test plan
cargo checkpassesMISE_TRACE=1 mise hook-env -s fishto capture PATH state🤖 Generated with Claude Code
Note
Low Risk
Low risk: changes are limited to additional
trace!/debug!logging around environment/PATH propagation, without altering hook behavior or env resolution logic.Overview
Adds diagnostics to help debug cases where mise-managed tools are missing on
PATHduring hook execution.Vfox::mise_envnow emitstrace!logs showing thePATHpassed into themise_envhook, env module resolution logs the computedPATHgiven tomoduledirectives, and Luacmd.exec()logs whether it applied the mise-constructed registry environment vs inheriting the process env.Reviewed by Cursor Bugbot for commit b17e0b3. Bugbot is set up for automated code reviews on this repo. Configure here.