build error
exit code 9009
software development
troubleshooting
programming error

What does exited with code 9009 mean during this build?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Exit code 9009 means Windows cmd.exe could not find the program or command you tried to run. It is the Windows equivalent of "command not found" on Unix systems. The fix is almost always one of three things: the tool is not installed, its directory is not in PATH, or the build script has a typo in the command name.

This error shows up most often in Visual Studio build events, MSBuild scripts, npm scripts running on Windows, and CI pipelines using Windows runners. The number 9009 (hex 0x2331) is specific to cmd.exe and does not appear on Linux or macOS.

What Exit Code 9009 Actually Means

When cmd.exe tries to execute a command and cannot find a matching executable, internal command, batch file, or script, it returns exit code 9009. This is analogous to exit code 127 on Unix shells.

The error typically appears as:

 
'some-tool' is not recognized as an internal or external command,
operable program or batch file.
error MSB3073: The command "some-tool --version" exited with code 9009.

The first line is the actual diagnostic from cmd.exe. The second line is MSBuild (or whatever build system) reporting the non-zero exit code.

Most Common Causes

1. Tool Not Installed

The build script references a tool that is not installed on the machine. This is especially common when moving a project from one developer's machine to another, or when a CI runner does not have the same global tools installed.

batch
REM Build script expects webpack to be available globally
webpack --config webpack.config.js
REM If webpack-cli is not installed globally, this fails with 9009

Fix: Install the missing tool. For npm-based tools, prefer local installation over global:

bash
npm install --save-dev webpack webpack-cli
npx webpack --config webpack.config.js

2. Directory Not in PATH

The tool is installed but its directory is not in the system's PATH environment variable. cmd.exe only searches directories listed in PATH.

batch
REM Python is installed at C:\Python311 but PATH does not include it
python --version
REM 'python' is not recognized... exited with code 9009

Fix: Add the tool's directory to PATH:

batch
1REM Temporary (current session only)
2set PATH=%PATH%;C:\Python311
3
4REM Permanent (requires new terminal)
5setx PATH "%PATH%;C:\Python311"

Or use the full path in the build script:

batch
C:\Python311\python.exe --version

3. Typo in Command Name

A simple spelling mistake or wrong executable name produces the same error:

batch
REM Wrong: "dockr" instead of "docker"
dockr build -t myapp .

This is more common than you might expect, especially in copy-pasted build scripts.

4. Missing File Extension on Windows

On Windows, executables need their extension (.exe, .cmd, .bat) unless the extension is listed in the PATHEXT environment variable. Some tools install as .cmd files (like npm), and calling them without the extension from certain contexts can fail:

batch
1REM This may fail in some build event contexts
2npm install
3
4REM This is more reliable
5call npm install

The call keyword tells cmd.exe to invoke a batch file and return to the calling script afterward.

5. Build Events in Visual Studio

Visual Studio's Pre-build and Post-build events run inside cmd.exe. A common error is writing a command that works in PowerShell but not in cmd.exe:

 
1REM Visual Studio Pre-build event
2REM Wrong: PowerShell syntax in a cmd.exe context
3Get-Date > build-timestamp.txt
4
5REM Correct: Use cmd.exe syntax
6echo %DATE% %TIME% > build-timestamp.txt

Debugging Steps

Follow this checklist to diagnose exit code 9009 systematically:

Step 1: Identify the exact command that failed. The build output usually shows the full command before the error. Copy it.

Step 2: Open a cmd.exe window and run the command manually.

batch
cmd.exe /c "the-exact-command --with-args"

If it fails here too, the problem is the command itself, not the build system.

Step 3: Check if the tool exists.

batch
where some-tool

where is the Windows equivalent of which. If it returns "Could not find files for the given pattern(s)," the tool is not in PATH.

Step 4: Check PATH.

batch
echo %PATH%

Verify that the directory containing the tool is listed.

Step 5: Check PATHEXT.

batch
echo %PATHEXT%

Default value is .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC. If your tool has a non-standard extension, it may not be found without the explicit extension.

Fixing 9009 in Specific Build Systems

MSBuild / Visual Studio

Pre-build and post-build events run in cmd.exe. Use call before batch files and verify PATH:

xml
<PreBuildEvent>
  <Command>call npm install</Command>
</PreBuildEvent>

If the command is optional (the build should continue even if it fails), wrap it:

xml
<PreBuildEvent>
  <Command>call npm install || echo "npm install failed but continuing"</Command>
</PreBuildEvent>

npm Scripts on Windows

npm scripts execute through cmd.exe on Windows. Tools installed locally live in node_modules/.bin, which npm adds to PATH automatically during script execution. But directly calling npx or the tool from outside npm scripts may fail:

json
1{
2  "scripts": {
3    "build": "webpack --mode production",
4    "lint": "eslint src/"
5  }
6}

Running npm run build works because npm resolves webpack from node_modules/.bin. Running webpack --mode production directly in cmd may fail if webpack is not globally installed.

GitHub Actions (Windows Runners)

CI pipelines using windows-latest runners hit this error when a tool is not pre-installed:

yaml
1jobs:
2  build:
3    runs-on: windows-latest
4    steps:
5      - uses: actions/checkout@v4
6      - name: Install dependencies
7        run: npm ci
8      - name: Build
9        run: npx webpack --mode production
10        shell: cmd  # Explicitly use cmd.exe

Setting shell: cmd forces cmd.exe. Alternatively, use shell: bash on Windows runners to get Unix-like behavior through Git Bash.

Comparison: Exit Codes Across Platforms

ErrorPlatformMeaning
Exit code 9009Windows (cmd.exe)Command not found
Exit code 1Windows (cmd.exe)General error (catch-all)
Exit code 127Linux/macOS (bash/zsh)Command not found
Exit code 126Linux/macOS (bash/zsh)Permission denied (not executable)
Exit code 2Linux/macOS (bash/zsh)Misuse of shell command / syntax error

Common Pitfalls

  • Assuming a tool is installed globally on all machines. Use project-local installations and npx (or equivalent) instead of relying on global PATH.
  • Using PowerShell syntax in Visual Studio build events. Build events execute in cmd.exe by default, not PowerShell.
  • Forgetting call before .cmd or .bat files in build scripts. Without call, cmd.exe transfers control to the batch file and never returns to the calling script.
  • Debugging in PowerShell when the build runs in cmd.exe. A command that works in PowerShell may not work in cmd.exe and vice versa. Test in the same shell the build uses.
  • Ignoring the exit code with || exit 0 without understanding why the command failed. This suppresses the symptom but leaves the root cause in place.
  • Hardcoding absolute paths that only exist on one developer's machine. Use environment variables or relative paths instead.

Summary

  • Exit code 9009 means cmd.exe could not find the command. It is Windows-specific.
  • The three most common causes are: tool not installed, directory not in PATH, and typos in the command name.
  • Use where some-tool to check whether a tool is findable from cmd.exe.
  • Use call before .cmd and .bat files in build scripts to avoid silent failures.
  • Prefer project-local tool installations (node_modules/.bin, virtual environments) over global installations for reproducible builds.
  • On CI, explicitly set the shell and install all required tools as part of the pipeline setup.

Course illustration
Course illustration

All Rights Reserved.