Exit codes
What each mbt exit code means, which commands return it, and how to use the codes in scripts and on a build machine.
Every mbt command returns a small, fixed set of exit codes, so scripts and CI jobs can tell a failed build from a mistyped command. The wrapper scripts pass the code through unchanged.
The codes
| Code | Meaning | Typical causes |
|---|---|---|
0 | Success | The command did what it was asked |
1 | The work failed | Compile or link errors, a required tool missing in doctor, a failed cook or package step |
2 | Usage or setup problem | No engine install found, an invalid option value, a contradictory pair of options, a bad --project path, a release package without content keys |
3 | Shader compiler not found | DXC is missing when shaders must compile |
1: the work failed
The command ran and the result was a failure. build returns 1 when any module fails to compile or link, or when a rules file does not compile. doctor returns 1 when a required tool is missing. package returns 1 when a step fails, for example a cook error, a monolithic import check, or a release symbol upload that was attempted and failed.
A missing or too old C++ toolchain also ends build with 1: toolchain detection fails the build rather than returning a code of its own. Run mbt doctor to see what is missing.
2: the command could not run as asked
mbt returns 2 before doing any work when, for example:
- it cannot find the engine above the current directory (run it through
mbt.cmdat the root of the install); --platform,--targetsorpackage --targethas an unknown value;--hot-reloadis passed without-t;packagegets both--monolithicand--modular, a mobile platform, or an output folder that is not empty and does not look like an earlier package;--projectdoes not point at an existing.mproject;- a
releasepackage's project has no content keys and--unprotectedwas not passed.
3: shader compiler not found
package and package-android return 3 when they must compile shaders and the shader compiler (DXC) that ships with the install cannot be found; $VULKAN_SDK/Bin and PATH are fallbacks. Reinstall to restore it.
Using exit codes in scripts
.\mbt.cmd build -t MyGame --extra-source D:/Projects/MyGame/Source
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}