{"record":{"id":"e5ca088a68133ddc","repo":"langchain-ai/deepagents","slug":"error-could-not-clear-trusted-directories","errorCode":null,"errorMessage":"Error: Could not clear trusted directories.","messagePattern":"Error: Could not clear trusted directories\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/skills/commands.py","lineNumber":982,"sourceCode":"        match result:\n            case RevokeResult.REMOVED:\n                console.print(\n                    f\"{checkmark} Revoked trust for: {escape(str(target))}\",\n                    style=theme.PRIMARY,\n                )\n            case RevokeResult.NOT_FOUND:\n                # Report honestly, not a false success.\n                console.print(\n                    f\"[yellow]No trust entry found for:[/yellow] {escape(str(target))}\"\n                )\n            case _:  # pragma: no cover - exhaustiveness guard\n                assert_never(result)\n    elif command == \"clear\":\n        if not clear_trusted_skill_dirs():\n            console.print(\n                \"[bold red]Error:[/bold red] Could not clear trusted directories.\"\n            )\n            raise SystemExit(1)\n        if output_format == \"json\":\n            from deepagents_code.output import write_json\n\n            write_json(\"skills trust clear\", {\"cleared\": True})\n            return\n        console.print(\n            f\"{checkmark} Cleared all trusted skill directories.\",\n            style=theme.PRIMARY,\n        )\n    else:\n        from deepagents_code.ui import show_skills_trust_help\n\n        show_skills_trust_help()\n\n\ndef setup_skills_parser(\n    subparsers: Any,  # noqa: ANN401  # argparse subparsers uses dynamic typing\n    *,","sourceCodeStart":964,"sourceCodeEnd":1000,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/skills/commands.py#L964-L1000","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Check ownership/permissions on the profile directory and trust store file","Free disk space if the disk was full and retry","Remove the trust store file manually (after backup) so the next run starts with an empty store","Re-run `dcode skills trust clear` and confirm the success message"],"exampleFix":"// before\n$ dcode skills trust clear\n# Error: Could not clear trusted directories.\n// after\n$ ls -l ~/.deepagents/skills/trust.json && rm ~/.deepagents/skills/trust.json\n$ dcode skills trust clear  # now succeeds","handlingStrategy":"validation","validationCode":"import os\nfrom pathlib import Path\n\ndef can_clear_store(store: Path) -> bool:\n    return store.exists() is False or (os.access(store, os.W_OK) and os.access(store.parent, os.W_OK))","typeGuard":null,"tryCatchPattern":"if not clear_trusted_skill_dirs():\n    print('could not clear trusted directories; check store permissions')\n    raise SystemExit(1)","preventionTips":["Run the CLI as the user who owns the profile directory","Ensure the profile directory is writable and has free disk space","Back up trust.json before clearing","After clearing, verify with `skills trust list` that the store is empty"],"tags":["cli","trust-store","filesystem"],"backgroundTag":"trust-store-write-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}