{"record":{"id":"02cf1b44354c2b94","repo":"google-gemini/gemini-cli","slug":"workspace-path-resolvedpath-is-not-a-directory","errorCode":null,"errorMessage":"Workspace path ${resolvedPath} is not a directory","messagePattern":"Workspace path (.+?) is not a directory","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/a2a-server/src/config/config.ts","lineNumber":496,"sourceCode":"      if (\n        err &&\n        typeof err === 'object' &&\n        'code' in err &&\n        err.code === 'ENOENT'\n      ) {\n        if (isTestEnv) {\n          await fs.promises.mkdir(resolvedPath, { recursive: true });\n          stats = await fs.promises.stat(resolvedPath);\n        } else {\n          throw new Error(`Workspace path ${resolvedPath} does not exist`);\n        }\n      } else {\n        throw err;\n      }\n    }\n\n    if (!stats.isDirectory()) {\n      throw new Error(`Workspace path ${resolvedPath} is not a directory`);\n    }\n\n    return resolvedPath;\n  } catch (e) {\n    logger.error(`[CoderAgentExecutor] Error resolving workspace path: ${e}`);\n    throw e;\n  }\n}\n\nexport async function loadEnvironment(\n  isTrusted: boolean = false,\n  workspacePath: string = process.cwd(),\n): Promise<Record<string, string>> {\n  // For untrusted workspaces, we completely bypass workspace-level .env loading\n  // and only load environment variables from the user's trusted home directory.\n  let envFilePath: string | null = null;\n  if (isTrusted) {\n    envFilePath = await findEnvFile(workspacePath);","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/a2a-server/src/config/config.ts#L478-L514","documentation":"Thrown by validateWorkspacePath when fs.stat succeeds but stats.isDirectory() is false. The resolved workspace path exists but is a regular file (or socket/device), not a directory. The agent needs a directory to operate as the workspace root.","triggerScenarios":"CODER_AGENT_WORKSPACE_PATH resolves to a file (e.g. a package.json, a README, a tarball) rather than its parent directory; a path that was a directory replaced by a file.","commonSituations":"User sets the path to /repo/package.json by mistake; a deploy artifact overwrote a directory with a file; misconfigured init script passing a file path.","solutions":["Point CODER_AGENT_WORKSPACE_PATH at the parent directory, not a file.","If a file is squatting on the directory name, remove/rename it and recreate the directory.","Add a startup assertion in your deploy script: [ -d \"$CODER_AGENT_WORKSPACE_PATH\" ] || exit 1."],"exampleFix":"# before\nexport CODER_AGENT_WORKSPACE_PATH=/home/user/myproject/GEMINI.md\n# throws: is not a directory\n\n# after\nexport CODER_AGENT_WORKSPACE_PATH=/home/user/myproject","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\n\nconst ws = process.env.CODER_AGENT_WORKSPACE_PATH!;\nif (!fs.statSync(ws).isDirectory()) {\n  throw new Error(`CODER_AGENT_WORKSPACE_PATH (${ws}) must be a directory, not a file.`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always point CODER_AGENT_WORKSPACE_PATH at a project directory, never a file inside it.","Add a preflight script: [ -d \"$WS\" ] || exit 1.","If a file is squatting on the name, remove it and recreate as a directory.","Validate in your deploy tooling, not just at runtime."],"tags":["workspace","filesystem","config","startup"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}