google-gemini/gemini-cli · error

EACCES

EACCES

Error message

${validationError}

What it means

EACCES is returned by getCorrectedFileContent when the resolved real path passes resolveToRealPath but config.validatePathAccess(resolvedPath) returns a non-empty error string. The message is whatever validatePathAccess returned; code:'EACCES'.

Source

Thrown at packages/core/src/tools/write-file.ts:175

        correctedContent: proposedContent,
        fileExists: false,
        error: {
          message:
            'Failed to resolve path: ' +
            (err instanceof Error ? err.message : String(err)),
          code: 'EINVAL',
        },
      };
    }
  }

  const validationError = config.validatePathAccess(resolvedPath);
  if (validationError) {
    return {
      originalContent: '',
      correctedContent: proposedContent,
      fileExists: false,
      error: { message: validationError, code: 'EACCES' },
    };
  }

  try {
    originalContent = await config
      .getFileSystemService()
      .readTextFile(resolvedPath);
    fileExists = true; // File exists and was read
  } catch (err) {
    if (isNodeError(err) && err.code === 'ENOENT') {
      fileExists = false;
      originalContent = '';
    } else {
      // File exists but could not be read (permissions, etc.)
      fileExists = true; // Mark as existing but problematic
      originalContent = ''; // Can't use its content
      const error = {
        message: getErrorMessage(err),

View on GitHub (pinned to 5024443c72)

Solutions

  1. Move the target file under config.getTargetDir() / an allowed path.
  2. Extend config's allowed folders / folder trust settings to include the path.
  3. If the path is correct, check the message from validatePathAccess for the specific rule that blocked it.

Example fix

// before
{ file_path: '/home/user/elsewhere/x.ts' }
// after
{ file_path: 'src/x.ts' }  // inside the trusted workspace root
Defensive patterns

Strategy: validation

Validate before calling

// confirm access before invoking the write tool
const err = config.validatePathAccess(resolvedPath);
if (err) { /* pick a path inside the trusted root */ }

Type guard

function isAccessError(res: unknown): boolean {
  return typeof res === 'object' && res !== null && (res as any).error?.code === 'EACCES';
}

Try / catch

const res = await getCorrectedFileContent(config, filePath, content, signal);
if (res.error?.code === 'EACCES') { return toolResultError('Path not allowed: ' + res.error.message); }

Prevention

When it happens

Trigger: resolvedPath computed successfully -> validationError = config.validatePathAccess(resolvedPath) -> truthy -> return { error:{ message: validationError, code:'EACCES' } } at line 175.

Common situations: File is outside the configured workspace/allowlist; the project root changed since the path was computed; read-only folder policy blocks the write target; user pointed the tool at a path the CLI's folder trust settings exclude.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/e87bd31397818276. Report an issue: GitHub.