fix(windows): preserve Program Files env in exec_command - #25
Merged
Conversation
huangm199
force-pushed
the
fix/windows-command-env-programfiles
branch
from
August 18, 2026 12:32
810d6d3 to
19097ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
exec_commanddoes not inherit the normal Windows process environment.baseCommandEnv()intentionally rebuilds a small allowlisted environment before starting commands.On Windows, that allowlist currently omits two standard variables:
As a result, a process started by AgentDock does not see the same baseline Windows environment as the exact same process started from Explorer, Task Scheduler, or a normal terminal.
This is not NVIDIA-specific. NVIDIA
nvidia-smiis simply a concrete tool that exposes the problem reliably.Concrete reproduction
On the affected Windows machine, with AgentDock v0.7.6 and NVIDIA driver 610.88:
Outside AgentDock
Running
nvidia-smias the same Windows user succeeds normally and reports the GPU, temperature, memory usage, utilization, power, and processes.Through AgentDock
exec_commandThe exact same executable exits immediately with:
This initially looks like a broken NVIDIA driver or broken NVML installation, but additional checks show that is a false diagnosis:
nvml.dllinitializes successfully when called directly.nvidia-smi.exeandnvml.dllhave valid signatures and matching driver versions.nvidia-smi.exeas the same Windows user outside AgentDock works.Replacing the AgentDock child-process environment with a normal Windows environment makes
nvidia-smisucceed immediately.Testing the environment differences individually then isolates the failure to the missing Program Files variables: restoring either
PROGRAMFILESorPROGRAMW6432is sufficient fornvidia-smito start normally.Why this matters
Without this fix, AgentDock can make a healthy Windows installation look broken from inside
exec_command.That has several practical consequences:
False hardware/driver diagnostics
nvidia-smifalsely reported an NVML initialization failure while NVML itself was healthy.Incorrect automation decisions
Program discovery failures
Different behavior inside vs. outside AgentDock
Misleading health checks
The NVIDIA failure is therefore a reproducible symptom of a more general Windows command-environment compatibility issue.
Fix
Preserve these two standard Windows variables in
baseCommandEnv():A Windows-only regression test verifies that both survive command environment construction.
Why this fix is intentionally small
This PR does not change AgentDock to inherit the full host environment.
The existing allowlist/security model remains intact. Only two standard Windows installation-root variables that are already part of a normal Windows process environment are added.
So the behavior becomes more Windows-compatible without expanding command execution to arbitrary host environment variables.
Verification
Verified on Windows with AgentDock v0.7.6 / commit
fed8dafcb1b0and NVIDIA driver 610.88:go test ./internal/tool/commandpasses.go test ./internal/envstorepasses.PROGRAMFILESandPROGRAMW6432are present insideexec_command.nvidia-sminow succeeds directly through AgentDockexec_command.