{"record":{"id":"62cdd260499684ec","repo":"langchain-ai/deepagents","slug":"invalid-deepagents-home-configured-r-use-an-abs-62cdd2","errorCode":null,"errorMessage":"Invalid DEEPAGENTS_HOME {configured!r}: use an absolute path or a path beginning with '~/'.","messagePattern":"Invalid DEEPAGENTS_HOME (.+?): use an absolute path or a path beginning with '~/'\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py","lineNumber":134,"sourceCode":"        return Path(explicit).expanduser()\n    try:\n        from deepagents_code._paths import get_deepagents_home  # noqa: PLC2701\n    except ImportError:\n        # Standalone fallback. It must apply the same rules as\n        # `_paths._resolve_profile_root`: relative paths and `~user` forms are\n        # rejected rather than coerced, because a lenient reading here would\n        # silently inspect a different profile than the app uses.\n        configured = os.environ.get(\"DEEPAGENTS_HOME\")\n        if not configured:\n            home = Path.home() / \".deepagents\"\n        elif configured.startswith(\"~/\"):\n            home = Path.home() / configured[2:].lstrip(\"/\")\n        elif configured.startswith(\"~\") or not Path(configured).is_absolute():\n            msg = (\n                f\"Invalid DEEPAGENTS_HOME {configured!r}: use an absolute path \"\n                \"or a path beginning with '~/'.\"\n            )\n            raise SystemExit(msg) from None\n        else:\n            home = Path(configured)\n    else:\n        home = get_deepagents_home()\n    return home / \".state\" / \"sessions.db\"\n\n\ndef _connect_read_only(path: Path) -> sqlite3.Connection:\n    resolved = path.expanduser().resolve()\n    if not resolved.is_file():\n        msg = f\"Sessions database not found: {resolved}\"\n        raise SystemExit(msg)\n    conn = sqlite3.connect(f\"{resolved.as_uri()}?mode=ro\", uri=True)\n    conn.row_factory = sqlite3.Row\n    tables = {\n        row[0]\n        for row in conn.execute(\n            \"SELECT name FROM sqlite_master WHERE type = 'table'\"","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py#L116-L152","documentation":"The thread-inspector resolves the sessions database location from the `DEEPAGENTS_HOME` environment variable; the value must be an absolute path or start with `~/`. `_default_db_path` (called while building the CLI parser) raises SystemExit with this message for any relative path or bare `~` form it cannot expand, because such values would resolve to an unpredictable directory.","triggerScenarios":"Exporting `DEEPAGENTS_HOME` to a relative path like `DEEPAGENTS_HOME=data` or a malformed tilde form like `DEEPAGENTS_HOME=~x/y` (tilde not followed by `/`), then running inspect_sessions.py.","commonSituations":"Shell config exporting DEEPAGENTS_HOME without `$HOME` expansion (unquoted `~` in some contexts); typos like a leading dot-relative path; copying a config from another tool expecting relative homes.","solutions":["Set `DEEPAGENTS_HOME` to an absolute path: `export DEEPAGENTS_HOME=/home/user/.deepagents`.","Use the tilde form correctly: `export DEEPAGENTS_HOME=~/.deepagents` (must start with `~/`).","Unset `DEEPAGENTS_HOME` to fall back to `get_deepagents_home()` defaults.","Fix your shell profile so the variable is expanded at export time (use `$HOME` or quote correctly)."],"exampleFix":"// before\nexport DEEPAGENTS_HOME=.deepagents   # relative path -> SystemExit\n// after\nexport DEEPAGENTS_HOME=\"$HOME/.deepagents\"","handlingStrategy":"validation","validationCode":"import os\nconfigured = os.environ.get('DEEPAGENTS_HOME')\nif configured and (configured.startswith('~') and not configured.startswith('~/') or not configured.startswith('~') and not os.path.isabs(configured)):\n    del os.environ['DEEPAGENTS_HOME']  # fall back to default instead of SystemExit","typeGuard":"def deepagents_home_is_valid(configured: str) -> bool:\n    return configured.startswith('~/') or os.path.isabs(configured)","tryCatchPattern":null,"preventionTips":["Set DEEPAGENTS_HOME to an absolute path or correct `~/` form in shell profiles.","Use \"$HOME/...\" instead of a bare relative path when exporting the variable.","Unset the variable to rely on get_deepagents_home() defaults."],"tags":["environment","configuration","path-validation","script"],"backgroundTag":"invalid-env-var-path","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}