Skip to content

Installed a tool, still 'not found' — your session's PATH is a snapshot

env paths · case

bothmisleading-errorscriptinteractiveagentfirst-partyrepro: verifiedregistry-env-snapshot
Affectsnode, powershell 51, pwsh 7, windows
Fails asCOMMAND NOT RECOGNIZED
Mechanismregistry env snapshot
Safe fixenv remerge

An installer runs winget install node (or similar), the install succeeds, and the very next line — node --version — fails with “not recognized”. The user opens a NEW terminal and it works. Agents retry the install in a loop.

Terminal window
winget install OpenJS.NodeJS ; node --version
# 'node' is not recognized as the name of a cmdlet...
# New terminal: node --version → works.

Installers write PATH to the REGISTRY (Machine/User scope). $env:Path is a process-creation snapshot of that merge — it never refreshes itself. Everything the current session spawns inherits the stale copy, so the just-installed tool is invisible until a new process re-reads the registry.

Terminal window
$env:Path = [Environment]::GetEnvironmentVariable('Path','Machine') + ';' +
[Environment]::GetEnvironmentVariable('Path','User')

Re-merge from the registry after any install step (the referenced installer does exactly this between winget and the first node call). Scope-read before writing, per envpath-pollutes-user — the two traps are mirror images.