Skip to content

Exit codes & errors

Every rereel invocation ends with one of five exit codes. The same numbers are exported as constants and used as RereelError.code in the API.

Code Constant Meaning
0 EXIT_OK Success (including --help and validate with valid: true).
1 EXIT_FAIL The operation ran but its result is wrong: invalid bundle, integrity failure, missing data at run time. Also used for unexpected (non-RereelError) exceptions.
2 EXIT_USAGE Bad invocation or bad input files: missing/unknown arguments, non-numeric flags, missing or invalid JSON, invalid configuration.
3 EXIT_DEPENDENCY A required external program or template is not installed.
4 EXIT_COMMAND An external program or remote service failed.
  • validate finished with valid: false (the report is printed as normal output, not as an error object).
  • hydrate/build: SHA-256 mismatch after download, --offline with a missing or stale asset, lock item without uri, provider did not write the file, local-cache object missing.
  • build: rendered chunk has the wrong frame count, composite media part not found, audio file referenced by mix_plan.json not found.
  • Any unexpected exception (e.g. a JavaScript TypeError or filesystem error) → {"status":"error","code":1,"error":"<String(err)>"}.
  • Unknown command (Unknown command: <cmd>) or patch operation (Unknown patch op: <op>).
  • Missing positional/required flags (freeze requires <reel_dir>, cut-retakes requires --input <path>, ripple-shift requires --at-sec and --delta-sec, trim-segment requires --id, swap-asset requires --old and --new, …).
  • Non-numeric numeric flag (Flag --fps must be a number: abc).
  • A required JSON file is missing (File not found: …) or unparseable (Invalid JSON in …), including the storage config.
  • Storage configuration problems: unknown provider name (details include available), unsupported provider type, S3 without bucket or credentials, invalid s3:// URI, command provider without storeCommand/resolveCommand, storing via the read-only http provider.
  • build: duration not determinable, no template, Remotion entry not found, invalid local/storage template ref, composite without parts, mix plan without positive duration_sec.
  • cut-retakes: input not found or duration undetectable.
  • patch trim-segment: narration segment ID not found.
  • An executable could not be spawned (ENOENT): ffmpeg, ffprobe, the Remotion CLI, npm, npx, tar, cp, mv, /bin/sh. Details include command.
  • build: a builtin template was not found under $REREEL_TEMPLATES_DIR or ~/.samurai/templates/remotion.
  • An external process exited non-zero (Remotion render, FFmpeg, npm ci, tar, a storeCommand/resolveCommand) or timed out. Details include exitCode, the last 1500 characters of stderr, and the last 500 characters of stdout. The message ends with the last stderr line.
  • S3 PUT/GET or HTTP GET returned a non-2xx status.
  • storeCommand produced no URI. resolveCommand produced no usable file (details include stdout).
  • Two-pass loudnorm measurements could not be parsed.

On failure the CLI prints exactly one line to stdout and exits with code:

{
status: "error";
code: number; // same as the process exit code
error: string; // human-readable message
...details // RereelError.details spread at the top level (optional)
}

Examples:

{"status":"error","code":2,"error":"Unknown command: bogus"}
{"status":"error","code":2,"error":"Unknown storage provider: r2","available":["local-cache","http"]}
{"status":"error","code":4,"error":"Command failed (exit 1): npx remotion render src/index.ts Main -- Error: Composition \"Main\" not found","exitCode":1,"stderr":"…","stdout":""}
{"status":"error","code":1,"error":"Missing or mismatched local asset in offline mode: media/bg_1a2b3c4d.png","relPath":"media/bg_1a2b3c4d.png","uri":"cas://1a2b3c4d….png"}

Because details keys are spread next to status, code, and error, check status === "error" first and read the extra keys only when present.

Terminal window
out=$(rereel build ./reels/ep01)
case $? in
0) echo "$out" | jq -r '.outPath' ;;
2) echo "usage/config problem: $(echo "$out" | jq -r '.error')" >&2 ;;
3) echo "install ffmpeg/remotion first" >&2 ;;
*) echo "$out" | jq . >&2 ;;
esac