Skip to content
Latchkey

Windows "The term 'X' is not recognized" (PATH) in CI

PowerShell could not find an external executable on PATH. The tool may be installed, but the directory holding its .exe is not on the PATH visible to this step.

What this error means

A CLI you expect (node, dotnet, terraform, a freshly installed tool) reports CommandNotFoundException. It is deterministic and usually appears right after an install step that updated PATH in a way the next step did not pick up.

powershell
terraform : The term 'terraform' is not recognized as the name of a cmdlet,
function, script file, or operable program.
    + CategoryInfo          : ObjectNotFound: (terraform:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Common causes

PATH update did not carry to the next step

Each workflow step gets a fresh process. Modifying $env:PATH inside one run: block does not affect later steps; the new directory is gone by the next step.

Installer put the binary somewhere not on PATH

choco, a zip extract, or a dotnet tool may drop the exe in a folder that is not on the machine PATH, so the command is unresolvable even though the file exists.

How to fix it

Append to PATH the GitHub Actions way

Write the directory to $GITHUB_PATH so every subsequent step sees it, instead of mutating $env:PATH locally.

powershell
# adds C:\tools to PATH for all later steps
Add-Content -Path $env:GITHUB_PATH -Value 'C:\tools'

Call the executable by full path

If you only need it in one step, invoke it with its absolute path and the & call operator.

powershell
& 'C:\ProgramData\chocolatey\bin\terraform.exe' version

Locate where the tool actually landed

  1. Use Get-Command -All or Where.exe to find the binary.
  2. Run: Get-ChildItem -Recurse -Filter terraform.exe C:\ -ErrorAction SilentlyContinue if you are unsure.
  3. Prefer a setup action that exports PATH for you over manual extraction.

How to prevent it

  • Persist PATH changes through $GITHUB_PATH, not $env:PATH, and verify a tool resolves with Get-Command immediately after installing it.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →