{"record":{"id":"863f897e5133ff55","repo":"langchain-ai/deepagents","slug":"dcode-message","errorCode":null,"errorMessage":"dcode: {message}","messagePattern":"dcode: (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/__init__.py","lineNumber":56,"sourceCode":"\n    Note:\n        Any import error other than an unresolvable profile location\n        propagates unchanged; `DeepAgentsHomeError` is reported as a message\n        plus exit 2 instead of a traceback.\n    \"\"\"\n    if name == \"cli_main\":\n        try:\n            from deepagents_code.main import cli_main\n        except DeepAgentsHomeError as exc:\n            # `_paths` resolves the profile at import, so a bad DEEPAGENTS_HOME\n            # or an unresolvable home surfaces here. Report it as a message\n            # rather than a traceback: the user has a value to fix, and every\n            # module that imports `_paths` would fail the same way.\n            message = str(exc)\n\n            def cli_main() -> None:\n                print(f\"dcode: {message}\", file=sys.stderr)  # noqa: T201\n                raise SystemExit(2)\n\n        return cli_main\n    msg = f\"module {__name__!r} has no attribute {name!r}\"\n    raise AttributeError(msg)\n","sourceCodeStart":38,"sourceCodeEnd":61,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/__init__.py#L38-L61","documentation":"`deepagents_code.__getattr__` provides `cli_main` lazily; if importing `deepagents_code.main` raises `DeepAgentsHomeError` (the dcode home/profile directory could not be resolved), it returns a stub `cli_main` that prints `dcode: {message}` to stderr and exits with status 2 instead of a traceback. The message names the actual home-resolution problem to fix.","triggerScenarios":"Running the `dcode`/`deepagents-code` entry point when `DEEPAGENTS_HOME` points somewhere invalid/unusable, or `_paths` cannot resolve a home directory during import of `deepagents_code.main`.","commonSituations":"`DEEPAGENTS_HOME` set to a non-writable or nonexistent path in shell profile or CI; a read-only container filesystem; a typo'd env var value; running under a user whose HOME is unset.","solutions":["Read the message after `dcode:` — it names the exact home-resolution failure; fix that path or permission","Unset or correct the `DEEPAGENTS_HOME` environment variable (or set it to a writable directory) and retry","Verify the target directory exists and is writable by the current user (`mkdir -p <dir> && touch <dir>/.write-test`)","In CI/containers, ensure a writable HOME or an explicit valid DEEPAGENTS_HOME is provided"],"exampleFix":"# before\nDEEPAGENTS_HOME=/nonexistent/path dcode\n# after\nexport DEEPAGENTS_HOME=\"$HOME/.dcode\"\nmkdir -p \"$DEEPAGENTS_HOME\"\ndcode","handlingStrategy":"try-catch","validationCode":"import os\nhome = os.environ.get(\"DEEPAGENTS_HOME\", os.path.expanduser(\"~/.dcode\"))\nif not os.path.isdir(home) or not os.access(home, os.W_OK):\n    os.makedirs(home, exist_ok=True)  # or fix DEEPAGENTS_HOME before launching","typeGuard":null,"tryCatchPattern":"# shell level: capture exit code 2 and the `dcode:` message\nif ! out=$(dcode 2>&1); then\n  if [[ $out == dcode:* ]]; then echo \"$out\"; fi\nfi","preventionTips":["Keep DEEPAGENTS_HOME pointing at an existing, writable directory","Fix HOME/unwritable paths in CI containers before installing dcode","Check shell profiles for stale or typo'd DEEPAGENTS_HOME values","Treat any `dcode:` stderr line with exit code 2 as a config problem, not a crash"],"tags":["cli","startup","environment","exit-code-2","dcode"],"backgroundTag":"missing-env-var","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}