google-gemini/gemini-cli · error · Error
Workspace path ${resolvedPath} is not a directory
Error message
Workspace path ${resolvedPath} is not a directory What it means
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.
Source
Thrown at packages/a2a-server/src/config/config.ts:496
if (
err &&
typeof err === 'object' &&
'code' in err &&
err.code === 'ENOENT'
) {
if (isTestEnv) {
await fs.promises.mkdir(resolvedPath, { recursive: true });
stats = await fs.promises.stat(resolvedPath);
} else {
throw new Error(`Workspace path ${resolvedPath} does not exist`);
}
} else {
throw err;
}
}
if (!stats.isDirectory()) {
throw new Error(`Workspace path ${resolvedPath} is not a directory`);
}
return resolvedPath;
} catch (e) {
logger.error(`[CoderAgentExecutor] Error resolving workspace path: ${e}`);
throw e;
}
}
export async function loadEnvironment(
isTrusted: boolean = false,
workspacePath: string = process.cwd(),
): Promise<Record<string, string>> {
// For untrusted workspaces, we completely bypass workspace-level .env loading
// and only load environment variables from the user's trusted home directory.
let envFilePath: string | null = null;
if (isTrusted) {
envFilePath = await findEnvFile(workspacePath);View on GitHub (pinned to 5024443c72)
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.
Example fix
# before export CODER_AGENT_WORKSPACE_PATH=/home/user/myproject/GEMINI.md # throws: is not a directory # after export CODER_AGENT_WORKSPACE_PATH=/home/user/myproject
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
const ws = process.env.CODER_AGENT_WORKSPACE_PATH!;
if (!fs.statSync(ws).isDirectory()) {
throw new Error(`CODER_AGENT_WORKSPACE_PATH (${ws}) must be a directory, not a file.`);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Workspace path ${resolvedPath} does not exist
- Workspace path ${resolvedPath} is outside the allowed root d
- [${logPrefix}] Unable to set GeneratorConfig. Please provide
- tar.c command failed to create ${tmpArchiveFile}
- The path "${trimmedPath}" is not a directory.
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/02cf1b44354c2b94.
Report an issue: GitHub.