Skip to content

fix(env): add trace logging for module hook PATH diagnostics#8981

Merged
jdx merged 2 commits intomainfrom
fix/module-env-trace-logging
Apr 9, 2026
Merged

fix(env): add trace logging for module hook PATH diagnostics#8981
jdx merged 2 commits intomainfrom
fix/module-env-trace-logging

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Apr 9, 2026

Summary

All at trace! level — only visible with MISE_TRACE=1, zero cost in normal operation.

Test plan

🤖 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 PATH during hook execution.

Vfox::mise_env now emits trace! logs showing the PATH passed into the mise_env hook, env module resolution logs the computed PATH given to module directives, and Lua cmd.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.

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>
Comment thread src/config/env_directive/mod.rs Outdated
- 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-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 9, 2026

Greptile Summary

Adds trace!-level diagnostics across three sites to help debug cases where mise-managed tools aren't found during vfox mise_env hook execution (MISE_TRACE=1 only, zero cost otherwise). The vfox.rs and env_directive/mod.rs additions are clean and consistent; cmd.rs logs at debug! instead of trace!, which is a minor inconsistency with the stated design but otherwise harmless.

Confidence Score: 5/5

Safe 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 — debug! should be trace! to match PR intent

Vulnerabilities

No security concerns identified. The debug! log in cmd.rs exposes the command string at MISE_DEBUG=1, but log output is local to the developer's terminal and not persisted or transmitted.

Important Files Changed

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"]
Loading

Fix All in Claude Code

Reviews (2): Last reviewed commit: "fix(env): gate PATH logging on log level..." | Re-trigger Greptile

Comment thread src/config/env_directive/mod.rs
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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}");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b17e0b3. Configure here.

@jdx jdx enabled auto-merge (squash) April 9, 2026 16:46
Copy link
Copy Markdown
Contributor

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

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 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 {
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.

medium

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.

Suggested change
} else {
trace!("module {name}: no PATH in env_map");

@jdx jdx merged commit 2441aa3 into main Apr 9, 2026
37 checks passed
@jdx jdx deleted the fix/module-env-trace-logging branch April 9, 2026 16:56
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

Hyperfine Performance

mise x -- echo

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%

mise-en-dev added a commit that referenced this pull request Apr 10, 2026
### 🚀 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)
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.

1 participant