langchain-ai/deepagents · error · SystemExit

Error: Could not clear trusted directories.

Error message

Error: Could not clear trusted directories.

What it means

The `skills trust clear` subcommand calls `clear_trusted_skill_dirs()`; if it returns a falsy value the store could not be cleared, so `_trust` prints `Error: Could not clear trusted directories.` and raises `SystemExit(1)`. This prevents a success message or `"cleared": true` JSON envelope when the on-disk store was not actually reset.

Source

Thrown at libs/code/deepagents_code/skills/commands.py:982

        match result:
            case RevokeResult.REMOVED:
                console.print(
                    f"{checkmark} Revoked trust for: {escape(str(target))}",
                    style=theme.PRIMARY,
                )
            case RevokeResult.NOT_FOUND:
                # Report honestly, not a false success.
                console.print(
                    f"[yellow]No trust entry found for:[/yellow] {escape(str(target))}"
                )
            case _:  # pragma: no cover - exhaustiveness guard
                assert_never(result)
    elif command == "clear":
        if not clear_trusted_skill_dirs():
            console.print(
                "[bold red]Error:[/bold red] Could not clear trusted directories."
            )
            raise SystemExit(1)
        if output_format == "json":
            from deepagents_code.output import write_json

            write_json("skills trust clear", {"cleared": True})
            return
        console.print(
            f"{checkmark} Cleared all trusted skill directories.",
            style=theme.PRIMARY,
        )
    else:
        from deepagents_code.ui import show_skills_trust_help

        show_skills_trust_help()


def setup_skills_parser(
    subparsers: Any,  # noqa: ANN401  # argparse subparsers uses dynamic typing
    *,

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Check ownership/permissions on the profile directory and trust store file
  2. Free disk space if the disk was full and retry
  3. Remove the trust store file manually (after backup) so the next run starts with an empty store
  4. Re-run `dcode skills trust clear` and confirm the success message

Example fix

// before
$ dcode skills trust clear
# Error: Could not clear trusted directories.
// after
$ ls -l ~/.deepagents/skills/trust.json && rm ~/.deepagents/skills/trust.json
$ dcode skills trust clear  # now succeeds
Defensive patterns

Strategy: validation

Validate before calling

import os
from pathlib import Path

def can_clear_store(store: Path) -> bool:
    return store.exists() is False or (os.access(store, os.W_OK) and os.access(store.parent, os.W_OK))

Try / catch

if not clear_trusted_skill_dirs():
    print('could not clear trusted directories; check store permissions')
    raise SystemExit(1)

Prevention

When it happens

Trigger: `skills trust clear` when `clear_trusted_skill_dirs()` fails to write or reset the trust store — unwritable file, unwritable parent directory, or an I/O error while replacing the store.

Common situations: Running the CLI as a different user than the one who owns the profile directory; read-only home or NFS mount; disk-full conditions while rewriting the trust store.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/e5ca088a68133ddc. Report an issue: GitHub.