google-gemini/gemini-cli · error
The path "${trimmedPath}" does not exist.
Error message
The path "${trimmedPath}" does not exist. What it means
When fs.stat() throws an ENOENT error inside validateWorkspacePath(), the catch block intercepts it and re-throws with this user-friendly message. The path passed the null-byte and containment checks but does not exist on disk.
Source
Thrown at packages/a2a-server/src/utils/path_utils.ts:58
// Check if the resolved path is within the allowed root directory
if (
canonicalWorkspacePath !== canonicalAllowedRoot &&
!isSubpath(canonicalAllowedRoot, canonicalWorkspacePath)
) {
throw new Error(
`Security violation: The path "${trimmedPath}" is outside the allowed root directory.`,
);
}
const stats = await fs.promises.stat(canonicalWorkspacePath);
if (!stats.isDirectory()) {
throw new Error(`The path "${trimmedPath}" is not a directory.`);
}
return canonicalWorkspacePath;
} catch (e) {
if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {
throw new Error(`The path "${trimmedPath}" does not exist.`);
}
throw e; // Re-throw other errors
}
}
View on GitHub (pinned to 5024443c72)
Solutions
- Create the directory (fs.mkdir or fse.ensureDir) before calling validateWorkspacePath.
- Verify the path spelling and ensure it matches the actual filesystem layout.
- Ensure the process CWD matches expectations when using relative allowedRoot defaults.
Example fix
// before
const dir = await validateWorkspacePath('./myworkspace'); // throws if not on disk
// after
import { ensureDir } from 'fs-extra';
await ensureDir('./myworkspace');
const dir = await validateWorkspacePath('./myworkspace'); Defensive patterns
Strategy: try-catch
Validate before calling
import fse from 'fs-extra';
async function ensureWorkspaceExists(path: string): Promise<void> {
await fse.ensureDir(path);
}
// Before validation:
await ensureWorkspaceExists(workspacePath);
const safe = await validateWorkspacePath(workspacePath); Try / catch
try {
const dir = await validateWorkspacePath(candidate);
} catch (e) {
if (e instanceof Error && e.message.includes('does not exist')) {
await fse.ensureDir(candidate);
// retry or handle
} else {
throw e;
}
} Prevention
- Create workspace directories with fse.ensureDir before validation.
- Verify path spelling against the actual filesystem layout.
- Avoid TOCTOU races by not deleting directories between validation and use.
When it happens
Trigger: Calling validateWorkspacePath() with a well-formed path within the allowed root that simply doesn't exist on the filesystem — e.g., a directory that hasn't been created yet or was deleted.
Common situations: Typo in path; directory not yet created; wrong working directory; race condition where the directory was removed between the containment check and the stat call.
Related errors
- The path "${trimmedPath}" is not a directory.
- Workspace path ${resolvedPath} does not exist
- Workspace path ${resolvedPath} is not a directory
- tar.c command failed to create ${tmpArchiveFile}
- Missing mount path '${from}' listed in SANDBOX_MOUNTS
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/e67649709e3aaddc.
Report an issue: GitHub.