Exit codes

Exit codes

loot uses few exit codes. 0 means the verb did what you asked and 1 means it failed or refused. A verb that records a conflict exits 2, and a few verbs whose answer is yes, no or "which one?" use 2 and 3.

CodeMeaningReturned by
0Success. That includes answers that look negative but were measured: a loot seek with no hits, a loot diff that found changes, and a loot conflicts that lists open conflicts.Every verb
1Failure or refusal; the reason is on stderr. It is also how a check reports a problem (loot verify found damage, loot doctor had a failing check), and what you get when a write to stdout fails (a reader closing the pipe early is not a failure).Every verb
2A negative answer, not an error: no landmark carries the role you named, or a gate or pipeline step refused. From a verb that merges, it means the verb did its work and recorded a conflict.loot buoy <role>, loot gates --run, loot pipeline run, and any verb that can record a conflict, such as pull, merge and revert
3Ambiguous: changes on separate lines of history carry the role, or two landmark names tie for nearest. loot names the candidates rather than pick one.loot buoy <role>, loot buoy --nearest
130You pressed Ctrl-C. The tutorial tries to remove its temp tree first and says whether it did.loot tutorial

Reading a failure

A failure prints loot: <message> on stderr. If you passed --json to a verb that takes it, stderr gets one JSON object instead, with a stable code you can branch on:

$ loot status --json
{"contract":14,"error":{"code":"no_repo","message":"not a loot repo at . or any parent directory (no .loot/). Run `loot init` first."}}
$ echo $?
1

A code is frozen once shipped. A failure nothing more specific names says error, so branch on the codes you know and treat the rest as a failure to read. The ones an agent meets first:

CodeWhat refused
no_repoNo .loot/ here or in any parent directory.
unknown_flag, bad_flag_valueThe verb does not take that flag, or cannot use its value.
needs_terminalOnly a person at a terminal, or the unattended source the message names, answers this.
custody_lockedThe keys are passphrase-locked and nothing unlocked them.
no_remoteThe verb needs a remote, and none is named or configured.
primary_only, not_lane_ownerA verb only the primary directory runs, asked from a lane; a lane another session spawned.
undo_barrierloot undo or loot op restore across a push, grant, burn or key filed, which undo cannot retract.
not_setloot config --get for a key no scope sets.
unmanaged_binaryloot update over a binary the installer did not write.
login_denied, login_expiredThe browser refused the sign-in, or nobody approved it in time.
no_passphrase_copyloot login: the forge keeps no passphrase copy of the account’s key, so a code cannot bring it here.
keypair_existsloot id import, recover or keygen in a repo that holds a key, without --replace.
rotation_is_the_forgesloot id rotate with a forge remote: there the account rotates the key.
contribution_door_shutloot propose to a repo whose owner has not run loot propose --door open.
lane_holds_unsignedloot lane land on a lane with unsigned work.
lane_holds_unlandedloot lane rm on a lane whose finalized change nothing else holds.
lands_through_mirrorloot lane land in a repo bound to a git mirror.
primary_does_not_authorNaming or finalizing a change in a primary that lanes share. Work in a lane.
no_such_version, ambiguous_versionA selector names nothing this repo holds, or more than one thing.
unauthenticatedThe host could not verify the request's signature.
not_allowlistedThe host verified your key and its operator has not listed it.
forbiddenThe forge verified your key and it may not do this here: the namespace belongs to another key or account, the key is retired, or the proposal door is shut.
taken_downThe forge's operator took the namespace down.
not_admitted, last_keyloot account open for a key the forge's door has not admitted; retiring an account's last live key.
no_accountThe key has no account at the forge: a collaborator loot member add names, or a key acting as an account. Its holder runs loot account open, then the owner adds it again.
not_foundThe forge has nothing there for this key: no such repo, or one it may not read. A forge answers the two alike.
over_planThe account's plan refused the push, runner or hosted agent.
rate_limitedThe key is past its rate. A later request can succeed.
nothing_servedA clone the remote served no change to: it holds none, or its history is not open to this key. A forge answers the two alike.
no_agent_key, bad_agent_key, out_of_scope, no_key_yet, no_such_path, needs_publish_consentFrom loot agent self, files, cat and propose: no key was given or it is not one; the path is outside the key's scope, has no key deposited yet, or is not on the head; the head's rules would publish a path without --allow-publish.
billing_unavailable, already_subscribedFrom loot plan upgrade: the forge sells no plan yet, or the account has one in effect.
would_drop_headThe push would drop a head the remote holds. Pull, or sign or abandon what the message names.

A refused capture or seal has its own codes too (demotion, mis_seal, lockout, publish, seal_wip, unauthorized), named for the gate that refused.

Porcelain and --json contracts covers that object.

Traps

  • A conflict exits 2, not 1. The verb did its work, reported each conflicted path (a C row under --porcelain) and stopped, so don’t retry it as a failure. loot conflicts exits 0 whatever it lists.
  • loot diff exits 0 whether or not anything changed. It has no --exit-code; read its --porcelain rows instead.
  • Where an empty answer would mislead, loot refuses with 1 instead: a loot status <path> that matches nothing, a loot cat of a path you cannot open, loot config --get of an unset key, and loot log --unpushed when the remote could not be asked.
  • For gates --run and pipeline run, 1 outranks 2: if one step could not start, you get 1 even though another refused. Each step's own exit code is in its row, not in loot's.
  • loot verify --unreachable lists objects nothing references but never changes the exit code. Unreachable is garbage, not damage.
  • In loot bisect run <cmd>, your command's status steers the search (0 good, 125 skip, anything else bad). It is not loot's exit code.