{"record":{"id":"dc8b5e6ef03a599a","repo":"langchain-ai/deepagents","slug":"path-is-neither-a-file-nor-a-directory-path","errorCode":null,"errorMessage":"Path is neither a file nor a directory: {path}","messagePattern":"Path is neither a file nor a directory: (.+?)","errorType":"exception","errorClass":"MarketplaceError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/plugins/marketplace.py","lineNumber":230,"sourceCode":"\n    msg = \"Invalid marketplace source format. Try: owner/repo, https://..., or ./path\"\n    raise MarketplaceError(msg)\n\n\ndef _marketplace_source_from_path(value: str) -> MarketplaceSource:\n    path = Path(value).expanduser().resolve()\n    if not path.exists():\n        msg = f\"Path does not exist: {path}\"\n        raise MarketplaceError(msg)\n    if path.is_file():\n        if path.suffix != \".json\":\n            msg = f\"File path must point to a .json marketplace file: {path}\"\n            raise MarketplaceError(msg)\n        return LocalMarketplaceSource(source_type=\"file\", value=str(path))\n    if path.is_dir():\n        return LocalMarketplaceSource(source_type=\"directory\", value=str(path))\n    msg = f\"Path is neither a file nor a directory: {path}\"\n    raise MarketplaceError(msg)\n\n\ndef _root_for_marketplace_file(path: Path) -> Path:\n    for relative in _MARKETPLACE_RELATIVE_PATHS:\n        if (\n            len(path.parts) >= len(relative.parts)\n            and path.parts[-len(relative.parts) :] == relative.parts\n        ):\n            return path.parents[len(relative.parts) - 1]\n    return path.parent\n\n\ndef _load_marketplace_file(path: Path) -> PluginMarketplace:\n    root = _root_for_marketplace_file(path.expanduser().resolve())\n    return _load_marketplace_from_path(root, path.expanduser().resolve())\n\n\ndef _run_git(args: list[str]) -> None:","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/plugins/marketplace.py#L212-L248","documentation":"After the existence, file, and directory checks, `_marketplace_source_from_path` raises this error if the resolved path is neither a regular file nor a directory (marketplace.py:227-230). In practice this catches special filesystem objects — sockets, FIFOs, device nodes, or broken symlinks whose target vanished after the `exists()` check — i.e. a rare TOCTOU or special-file situation.","triggerScenarios":"`parse_marketplace_source('/path/to/a/socket')` or a FIFO/device path passed as a marketplace source; a symlink whose target was deleted between the `path.exists()` check and the `is_file()`/`is_dir()` checks; calling `add_marketplace_source` with such a path.","commonSituations":"Accidentally pointing at a Unix socket (e.g. a Docker or SSH agent socket); shell completion selecting a device node; a race where a symlink is replaced/deleted mid-command.","solutions":["Point the source at a regular directory or a `.json` file instead of a special filesystem object.","If a symlink is involved, verify its target exists and is a directory or JSON file (`ls -l`, `readlink -f`).","Re-run the command if it was a transient race; the target may have been replaced."],"exampleFix":"// before\nadd_marketplace_source(\"/var/run/my-agent.sock\")\n// after\nadd_marketplace_source(\"/home/me/plugin-marketplaces/official\")","handlingStrategy":"validation","validationCode":"import os\nfrom pathlib import Path\n\ndef validate_regular_path(raw: str) -> str:\n    p = Path(raw).expanduser().resolve()\n    if not (os.path.isfile(p) or os.path.isdir(p)):\n        raise ValueError(f\"Not a regular file or directory: {p}\")\n    return raw","typeGuard":"import os\nfrom pathlib import Path\n\ndef is_regular_file_or_dir(value: str) -> bool:\n    p = Path(value).expanduser().resolve()\n    return os.path.isfile(p) or os.path.isdir(p)","tryCatchPattern":"try:\n    source = parse_marketplace_source(raw)\nexcept MarketplaceError as exc:\n    if \"neither a file nor a directory\" in str(exc):\n        raise ValueError(f\"{raw!r} is a special file (socket/FIFO/device); pass a directory or .json file\") from exc\n    raise","preventionTips":["Never point marketplaces at sockets, FIFOs, or device nodes.","Check symlinks resolve to real directories/files (`readlink -f`) before registering.","Treat repeated occurrences of this error as a symlink race and re-run after the filesystem settles."],"tags":["filesystem","edge-case","symlink"],"backgroundTag":"path-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}