# Troubleshooting

> Match an error message, status value, exit code, or client failure to its cause and the commands that fix it.

---

LLMS index: [llms.txt](/llms.txt)

---

Find what you are seeing in the table below and jump to its section; each one names the
likely cause and the commands that fix it. The examples use `/srv/sow` for the workspace,
`pgsql` for the repository, and `prod` for the publication target; replace them with
yours.

Collect the state before changing anything. `status` says whether the repository is
`clean`, `dirty`, `recovering`, or in `error`; `log` shows recent operations and which
one failed. Error messages keep SOW's internal names: most errors from workspace commands
(those that work on standard repositories) carry `managed:` after the error category, as
in `operation rejected: managed: operation rejected: …`, and errors from `create` and
`prune`, which work on simple repositories, start with `plain:`.

```bash
sow version
sow status -C /srv/sow -r pgsql
sow log -C /srv/sow -r pgsql
```

| What you see | Go to |
|---|---|
| `configuration error`, or `config check` exits `2` or `6` | [The configuration is rejected](#the-configuration-is-rejected) |
| `status` shows `dirty`; `check` exits `5` without naming a damaged file | [Status shows pending changes](#status-shows-pending-changes) |
| `status` shows `recovering`, a command exited `130`, or a process was killed | [A command was interrupted](#a-command-was-interrupted) |
| A nonzero exit, but the output lists committed packages or a new Generation | [Errors after a committed change](#errors-after-a-committed-change) |
| `publish` says the target is `already bound` | [Target configuration changed](#target-configuration-changed) |
| Exit `5` with `a target publication must roll forward`, `write-active publication attempt`, or `unfinished ... report` | [Publication and target GC wait for each other](#publication-and-target-gc-wait-for-each-other) |
| Exit `6` with `mutation would withdraw published pointer` | [A change would withdraw a published file](#a-change-would-withdraw-a-published-file) |
| A write command hangs, or exits `4` | [A command waits for a lock](#a-command-waits-for-a-lock) |
| A password prompt, `signing credential is unavailable`, or a key `unusable for signing` | [A signing key asks for a password or cannot unlock](#signing-password) |
| `add`, `build`, or `check` rejects a package file, signature, or path | [Other validation failures](#other-validation-failures) |
| `dnf`, `yum`, or `apt` cannot sync, install, or sees old content | [Client errors](#client-errors) |
| `repository schema migration required`, or trouble right after an upgrade | [After upgrading](#after-upgrading) |
{.wide .expand}

## The configuration is rejected {#the-configuration-is-rejected}

Every workspace command reads `sow.yml` first, so one mistake there stops all of them. Run
the check alone to see the first problem and the field it names:

```bash
sow config check -C /srv/sow
```

Exit `2` means the file itself is invalid: a YAML error, an unknown field (often a typo or
wrong indentation), a bad name, or a value outside its rule. Exit `6` means the file is
valid but contradicts recorded state or cannot resolve a signing key. The usual cause is
a repository or Dist deleted from the file by hand, or an architecture removed while
packages or built Generations still use it. Put the entry back; remove a repository or
Dist with `sow repo rm` or `sow dist rm` instead. A changed Dist `format` exits `5`; a
Dist's format is fixed once it exists. The [configuration reference](/docs/reference/config/)
lists every field's rule.

## Status shows pending changes

`status` reports `dirty` and lists `dirty_dists`, and `check` exits `5` although nothing is
damaged. `add --skip`, `rm --skip`, or a configuration edit committed a desired state that
has not been built yet. Clients still get the last built indexes, which are consistent but
are not what you declared. Build and check:

```bash
sow build -C /srv/sow -r pgsql
sow check -C /srv/sow -r pgsql
```

A local build updates the workspace only. To update a configured target as well, run
`sow publish prod -C /srv/sow`. See [`sow status`](/docs/command/status/) for each field.

## A command was interrupted

A command exited `130`, was killed, or lost power, and `status` may show `recovering`.
A standard repository journals each change before applying it, so an interrupted operation stays
pending until a later command finishes it or rolls it back. First fix whatever the
diagnostic reports (a full disk, a missing input, unreachable storage), then run the
command that recovers that operation:

| Interrupted | Run |
|---|---|
| `sow create` (simple repository) | The same command, with the same `--pigsty`, `--metadata-timestamp`, and signing options |
| `sow prune` (simple repository) | The same command, with the same `--protect` and `--metadata-timestamp` options |
| `add`, `rm`, a Dist change, or `build` | `sow build -C /srv/sow -r pgsql`; committed desired-state changes stay part of the pending build |
| `init`, `repo new`, or `repo rm` | The same lifecycle command again |
| Local `gc` or `retain rm` | `sow gc` or `sow retain rm GENERATION` again |
| R2 target deletion | `sow gc prod --delete` |
| `publish` | `sow publish prod`, described below |
{.wide .expand}

If recovery has to sign metadata with a protected key, supply the password again:
journals never store it. Use `--passfile PATH` or `SOW_GPG_PASSFILE` on the recovery
command; per-key `passfile` settings still apply. Do not edit `sow.yml` while an `init`,
`repo new`, or `repo rm` is pending, because recovery compares the file with the journal
and stops with an integrity error if it matches neither the old nor the new version. See
[Password files](/docs/reference/config/#passfile).

For an interrupted publication, restore access to the storage and the public endpoint,
then run the same target again. SOW resumes the saved attempt rather than starting over:

```bash
sow publish prod -C /srv/sow
```

Before the attempt records its commit intent, you can abandon it with
`sow publish prod --abort -C /srv/sow`. After commit intent, only rerunning `publish`
finishes it, and `--abort` exits `6`, as it does when there is no attempt to abandon.
Until the publication finishes, local changes and target GC wait for it; see
[Publication and target GC wait for each other](#publication-and-target-gc-wait-for-each-other),
[`publish`](/docs/command/publish/), and [Transactions and recovery](/docs/feature/transactions/).

## Errors after a committed change

A command exits nonzero, yet its output lists accepted packages or a new Generation.
Database commit and the maintenance that follows (a checkpoint, a cleanup) are separate
steps, so the second can fail after the first succeeded. SOW reports the committed items
as committed, not rolled back. Read the result and `sow status`, inspect the operation
with `sow log`, and run the command the diagnostic names. Keep the original input files
until you have confirmed the result.

## Target configuration changed

`sow publish` exits `1` with one of these messages:

- `already bound with different mutable configuration; rerun publish with --rebind after operator review`
- `already bound to different storage or prefix; configure a new target name`

The first publish recorded the target's binding, and `sow.yml` no longer matches it.
Compare the file with what you intended. If you meant to change the target name,
`public_endpoint`, or `max_cache_ttl`, accept the change:

```bash
sow publish prod --rebind -C /srv/sow
```

A different repository, provider, endpoint, region, bucket, or prefix cannot be rebound;
configure a new target under a new name. Finish pending target maintenance before
changing the TTL. See [Changing a target](/docs/reference/config/#publication-targets).

## Publication and target GC wait for each other {#publication-and-target-gc-wait-for-each-other}

A publication works from a frozen plan of the local tree, and publication and target GC
both change what the target holds. So an unfinished publication blocks local changes and
target GC, and an unfinished target GC report blocks publication. Each case exits `5`
and names the command that finishes the pending work:

| Message | Reported by | Run |
|---|---|---|
| `a target publication must roll forward before Repository bytes can change` | `add`, `rm`, `build`, `dist new`/`rm`, `repo rm`, `init` | `sow publish prod`, or `sow publish prod --abort` before commit intent |
| `target "prod" has write-active publication attempt ...` | `gc prod` | `sow publish prod`, or `--abort` before commit intent |
| `target "prod" has an unfinished candidate report; resume with gc prod` | `publish prod` | `sow gc prod` |
| `target "prod" has an unfinished conditional-delete report; resume with gc prod --delete` | `gc prod` (R2) | `sow gc prod --delete` |
{.wide .expand}

Then rerun the command that was blocked.

## A change would withdraw a published file {#a-change-would-withdraw-a-published-file}

`dist rm`, or a `build` that would remove a published RPM architecture view or metadata signature,
exits `6` with `mutation would withdraw published pointer "dists/..." from configured target "prod"`.
The target's published Generation protects the paths of repository entry points and their signature companions. Content-addressed indexes can rotate normally. To go ahead, first retire the target (remove it from `sow.yml`) or move it to a
new target and prefix, then repeat the change. To undo instead, restore the previous settings; the
repository returns to its built state.

## A command waits for a lock

A write command hangs, or exits `4` when run with `--no-wait` or `--timeout`. Another SOW
process holds the workspace or repository write lock, and writers wait without a limit by
default. `sow status` reports `locked=true` without waiting for that writer. Let the
other command finish, or stop it through its normal process controls, then retry.

In scripts, use `--no-wait` (`-N`) to return at once or `--timeout 30s` (`-T 30s`) to
bound the wait. These options apply to write commands only, not to `init` or read
commands. A read that needs a consistent snapshot waits for the writer until you cancel
it.

Leave the lock files in place: SOW coordinates processes through their fixed paths. If a
populated workspace has lost `.sow/workspace.lock`:

1. Stop every SOW process and scheduled job for the workspace.
2. As the workspace owner, exclusively create an empty `.sow/workspace.lock` with mode `0600`.
3. Run `sow init /srv/sow`, then restart the jobs.
{.steps .td-steps-compact}

See [Transactions and recovery](/docs/feature/transactions/#locks-and-waiting) for the lock
model.

## A package, signature, or path fails validation

### A signing key asks for a password or cannot unlock {#signing-password}

Signing prompts for a password, or fails with `signing credential is unavailable`,
`passfile ... is empty`, or a metadata key that is `unusable for signing`. The last one
is also what a wrong or missing password for an encrypted key file looks like. SOW takes
the password from `--passfile PATH`, then the key's `passfile`, then `SOW_GPG_PASSFILE`;
check the source that actually applies:

- **Path.** Command-line and environment paths are relative to the process working
  directory, regardless of `-C`; `sow.yml` paths are relative to the workspace root. An
  empty `SOW_GPG_PASSFILE` is an error, not the same as an unset one.
- **Content.** One nonempty line; an optional UTF-8 BOM and one final LF or CRLF are
  removed, and spaces and tabs count. It is not a shell script or a `NAME=value` line.
  Regular files, symlinks, and named pipes (with a 2-second writer deadline) work.
- **No fallback.** A broken selected source fails without trying another one or
  prompting. External GPG needs an agent that allows loopback mode, and a hardware key can
  still ask for its own confirmation.
- **Simple repositories.** `sow create` signs only with `--sign-with`; the environment
  variable alone does not enable signing.

`config check` unlocks metadata keys and probes external GPG metadata signing, so it
catches a wrong metadata password. For RPM package keys it checks only format, tools,
and key availability; confirm the password with a real package-signing build. `check`
verifies public signatures and never reads passwords. The full contract is in
[Password files](/docs/reference/config/#passfile).

### Other validation failures

Use the file and check stage named in the error:

| Error | Cause and fix |
|---|---|
| Same pool path, different bytes | A different package already uses this file name. Compare the two; give changed content a new version and file name. Moving the file to another input directory does not change its pool URL. |
| File name differs only by case | Case aliases cannot create a second pool URL. Use the spelling already recorded. |
| Missing or altered pool file | Restore the original bytes from a matching backup, then rerun `sow check`. |
| Signing key unavailable | Check the configured key, secret-key access, the GPG agent, and the key's validity, then rebuild. |
| RPM does not match the trust policy | Check the package signature against `key` and `trusted_keys`. See [Sign your repository](/docs/tutorial/signing/). |
{.wide .expand}

`sow check` reports integrity errors but never rewrites damaged data. Keep the reported
path and operation ID while you investigate. [Repository layout](/docs/reference/layout/)
shows which files belong to the pool, the generated indexes, and private state.

## Client errors {#client-errors}

| What the client does | Cause and fix |
|---|---|
| Gets old content or 404s from the public URL | Check the HTTP root, URL prefix, cache settings, and `max_cache_ttl`, then publish again. |
| `dnf reposync` refuses the package locations | A standard repository's RPM views point to `../../../pool/`, outside the directory `reposync` allows. Generate a self-contained copy with [`sow export rpm-leaf`](/docs/command/export/). |
| EL7 `yum` keeps the old package list after you switch generators | EL7 compares metadata timestamps with its cache. Use a new repository ID or clear its cache; see [Existing EL7 caches](/docs/reference/compatibility/#existing-el7-caches). |
| Modular packages are filtered, or `dnf module install` fails | SOW writes no module metadata. Set `module_hotfixes=1` for ordinary installs, or keep a tool that provides modules; see [XML and SQLite RPM metadata](/docs/reference/compatibility/#xml-and-sqlite-rpm-metadata). |
| A tool requires `primary_db` | SOW writes XML metadata only. YUM falls back to XML; other tools need an XML input or a conversion. |
{.wide .expand}

Test the actual client configuration before switching hosts; [Serve and publish](/docs/tutorial/serving/)
has client setup for both formats.

## After upgrading {#after-upgrading}

These problems come only from workspaces created by older SOW releases. Follow the
[upgrade guide](/docs/start/install/#upgrade-to-090) first; it covers backups and the
`max_cache_ttl: 0s` review.

### The database needs migration

Repositories created by 0.5.0 through 0.8.0 already use the same schema v13 as 0.9.0. Releases 0.2.0, 0.3.0, and 0.4.0 created schemas v8, v10, and v12 respectively. All three need migration. In 0.9.0, `sow status` can inspect v12 and returns `5` for v8 or v10. On all three schemas, `sow build` and `sow init` exit `6` and ask for migration.

Stop all writers and back up the complete workspace with hard links preserved. Then run the following commands for each repository.

```bash
sow repo migrate pgsql -C /srv/sow
sow build -C /srv/sow -r pgsql
sow check -C /srv/sow -r pgsql
```

### Leftovers from older releases {#leftovers-from-older-releases}

- **Interrupted 0.7.1 local GC plan** with an empty `manifest` array: run `sow gc` again;
  0.9.0 resumes it directly.
- **Invalid transition control target** after a build, in a repository migrated from C2
  layout by SOW 0.5 or 0.6: current releases recover this automatically.
- **Leftover C2 migration stage files block local GC**: rerun
  `sow repo migrate pgsql -C /srv/sow`. Files that SOW cannot prove safe to delete are
  kept under `.sow/pgsql/abandoned/` and their location is reported; inspect them before
  you remove them.
