Claude Code injects stale MSBUILD_EXE_PATH into shell environment on Windows

Resolved 💬 3 comments Opened Jan 18, 2026 by bobum Closed Jan 22, 2026

Claude Code appears to inject MSBUILD_EXE_PATH environment variable into spawned bash shells on Windows, even when the referenced path no longer exists.

Environment

  • OS: Windows 10/11
  • Claude Code version: latest
  • Shell: Git Bash (via WezTerm)

Steps to reproduce

  1. Install Visual Studio BuildTools 2026 (VS 18)
  2. Start Claude Code - it will detect MSBuild
  3. Uninstall Visual Studio BuildTools completely
  4. Restart machine and Claude Code
  5. In Claude Code's bash shell, run: echo $MSBUILD_EXE_PATH

Expected

Variable should be empty or not set

Actual

Variable still contains stale path:

MSBUILD_EXE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\MSBuild\Current\Bin\MSBuild.exe

Evidence that Claude Code sets this

  • Fresh PowerShell window after reboot: variable NOT present
  • Fresh bash subshell from Claude's shell (bash -l -c 'echo $MSBUILD_EXE_PATH'): variable NOT present
  • Claude Code's bash shell: variable IS present
  • Variable not in Windows registry (HKLM or HKCU Environment)
  • Variable not in Git Bash config files (/etc/profile, profile.d/*, ~/.bashrc)

Impact

Causes .NET SDK build failures with error: MSB4184: A required NuGet assembly could not be loaded pointing to non-existent VS path.

Workaround

Add unset MSBUILD_EXE_PATH to ~/.bashrc

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗