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.
| Code | Meaning | Returned by |
|---|---|---|
| 0 | Success. 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 |
| 1 | Failure 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 |
| 2 | A 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 |
| 3 | Ambiguous: 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 |
| 130 | You 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 $?
1A 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:
| Code | What refused |
|---|---|
no_repo | No .loot/ here or in any parent directory. |
unknown_flag, bad_flag_value | The verb does not take that flag, or cannot use its value. |
needs_terminal | Only a person at a terminal, or the unattended source the message names, answers this. |
custody_locked | The keys are passphrase-locked and nothing unlocked them. |
no_remote | The verb needs a remote, and none is named or configured. |
primary_only, not_lane_owner | A verb only the primary directory runs, asked from a lane; a lane another session spawned. |
undo_barrier | loot undo or loot op restore across a push, grant, burn or key filed, which undo cannot retract. |
not_set | loot config --get for a key no scope sets. |
unmanaged_binary | loot update over a binary the installer did not write. |
login_denied, login_expired | The browser refused the sign-in, or nobody approved it in time. |
no_passphrase_copy | loot login: the forge keeps no passphrase copy of the account’s key, so a code cannot bring it here. |
keypair_exists | loot id import, recover or keygen in a repo that holds a key, without --replace. |
rotation_is_the_forges | loot id rotate with a forge remote: there the account rotates the key. |
contribution_door_shut | loot propose to a repo whose owner has not run loot propose --door open. |
lane_holds_unsigned | loot lane land on a lane with unsigned work. |
lane_holds_unlanded | loot lane rm on a lane whose finalized change nothing else holds. |
lands_through_mirror | loot lane land in a repo bound to a git mirror. |
primary_does_not_author | Naming or finalizing a change in a primary that lanes share. Work in a lane. |
no_such_version, ambiguous_version | A selector names nothing this repo holds, or more than one thing. |
unauthenticated | The host could not verify the request's signature. |
not_allowlisted | The host verified your key and its operator has not listed it. |
forbidden | The 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_down | The forge's operator took the namespace down. |
not_admitted, last_key | loot account open for a key the forge's door has not admitted; retiring an account's last live key. |
no_account | The 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_found | The forge has nothing there for this key: no such repo, or one it may not read. A forge answers the two alike. |
over_plan | The account's plan refused the push, runner or hosted agent. |
rate_limited | The key is past its rate. A later request can succeed. |
nothing_served | A 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_consent | From 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_subscribed | From loot plan upgrade: the forge sells no plan yet, or the account has one in effect. |
would_drop_head | The 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
Crow under--porcelain) and stopped, so don’t retry it as a failure.loot conflictsexits 0 whatever it lists. loot diffexits 0 whether or not anything changed. It has no--exit-code; read its--porcelainrows instead.- Where an empty answer would mislead, loot refuses with 1 instead: a
loot status <path>that matches nothing, aloot catof a path you cannot open,loot config --getof an unset key, andloot log --unpushedwhen the remote could not be asked. - For
gates --runandpipeline 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 --unreachablelists 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.