Exit codes

The four exit codes espx uses, and the stable error codes that agents and scripts key on.

Exit codes

CodeWhen
0Success, including a --until match or the last --expect match
1Any other failure. espx prints one error: line on stderr that says what to do next
124--timeout ran out, with the output up to that point still printed (the coreutils timeout convention)
130A child process was killed by a signal, usually your Ctrl+C reaching cargo or espflash. espx prints nothing more

124 comes from --timeout on run, monitor and replay, whether or not there was a pattern to wait for. A rejected line (--reject) and a stream that ends with an expectation still pending are both 1.

espx doctor reports missing tools in its output and exits 0 either way. Read its --json output, or each check's status, to fail a script on a missing tool.

Error codes

Every error espx can raise has a stable code, the same name in snake case across the CLI, the MCP server and the board hub. The CLI prints only the message. The code appears in:

  • MCP tool results, as error.code in the structured content.
  • The agent audit log, as detail.code on a denied or failed call.
  • The JSON Schema, as the ErrorCode type in schema/espx.json.

Renaming a code is a breaking change, so these are safe to match on.

Projects and setup

CodeMeaning
not_projectThe directory has no Cargo.toml. Run espx new or pass --dir
rust_not_foundrustup and cargo are missing
xtensa_toolchain_missingAn Xtensa chip or project needs the esp toolchain. Run espx setup --chip <chip>
unknown_chipNot an id from espx chips
unknown_boardNot an id from espx boards
board_chip_mismatch--board and --chip disagree
bad_project_nameThe name is not a valid project name; the message says why
project_existsThe project folder already exists
not_a_directoryThe location is a file, not a folder
dependenciesNo Cargo.lock to read. Build first
tool_missingA tool espx needs is not installed. Run espx setup
tool_unavailableThe mirror publishes no build of a tool for this platform
unsupported_platformNo espx tools for this OS and architecture
shell_unsupported--shell only edits zsh and bash configs
nothing_selectedespx uninstall with no flag and no -i
not_a_tty-i without a terminal

Downloads and updates

CodeMeaning
fetchA download failed
manifestThe release or tool server answered with something espx cannot read
archive_missingA downloaded archive did not contain the expected binary. Nothing was installed
checksum_mismatchA download did not match its SHA-256. Nothing was installed
install_failedespx could not replace a binary on disk

Builds

CodeMeaning
build_failedcargo reported compile errors, or exited non-zero
image_too_largeThe image does not fit the app partition. Nothing was flashed

Boards

CodeMeaning
port_requiredNo board, or several and none chosen. Pass --port or bind one
board_not_attachedThe board named by a flag or by [board] id is not connected
board_unreachableespx could not talk to the board; check the cable and that nothing else holds the port
upload_corruptedThe bootloader received corrupted data, typically a WCH bridge on macOS's built-in driver
board_leasedAnother holder (a flash, an agent) is using the board
board_goneThe board did not come back after a flash or reset. Press reset or replug it
not_attachedNothing is monitoring the board. Attach first
session_closedThe monitor session closed. Attach again
bad_board_nameThe name has characters a board name cannot have
name_takenAnother board already has that name

Monitor and scripts

CodeMeaning
bad_patternA --until, --expect or --reject regex does not compile
bad_duration--timeout is not a duration like 30s or 2m
timeoutThe timeout ran out (exit 124)
monitor_closedThe stream ended before the pending pattern matched
rejectedA line matched a --reject pattern
monitor_extra_argsArguments after -- on monitor together with flags that make espx read the port itself
recordingA recording file could not be read

Configuration and agents

CodeMeaning
configespx.toml or boards.toml has an error; the message names the file, line and key
policy_deniedThe [agent] policy does not let an agent do this to this board; the message names the keys to set
policy_not_editableThe [agent] policy is written as an inline table or with dotted keys, so espx cannot edit it in place
client_configAn MCP client's config file cannot be read or parsed
client_not_foundThe claude or codex CLI is not installed where espx looks
client_command_failedclaude mcp add or codex mcp add failed
espx_not_foundThe desktop app cannot find the espx binary that MCP clients start

The board hub

CodeMeaning
hub_unreachableThe espx process serving the board hub went away. Run the command again
hub_servedAnother espx process already serves the board hub

General

CodeMeaning
command_failedA child command failed, or a tool result failed without an espx error (a cancelled job, a rejected run)
spawnespx could not start a program
env_captureSourcing ~/.espx/export-esp.sh failed
write_failedA file could not be written
delete_failedA file could not be deleted
interruptedA child was killed by a signal (exit 130)
ioAny other I/O error

The MCP server adds one code of its own, invalid_arguments, for a tool call whose arguments do not match the tool's schema.