{"record":{"id":"e87bd31397818276","repo":"google-gemini/gemini-cli","slug":"eacces","errorCode":"EACCES","errorMessage":"${validationError}","messagePattern":"\\$\\{validationError\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/tools/write-file.ts","lineNumber":175,"sourceCode":"        correctedContent: proposedContent,\n        fileExists: false,\n        error: {\n          message:\n            'Failed to resolve path: ' +\n            (err instanceof Error ? err.message : String(err)),\n          code: 'EINVAL',\n        },\n      };\n    }\n  }\n\n  const validationError = config.validatePathAccess(resolvedPath);\n  if (validationError) {\n    return {\n      originalContent: '',\n      correctedContent: proposedContent,\n      fileExists: false,\n      error: { message: validationError, code: 'EACCES' },\n    };\n  }\n\n  try {\n    originalContent = await config\n      .getFileSystemService()\n      .readTextFile(resolvedPath);\n    fileExists = true; // File exists and was read\n  } catch (err) {\n    if (isNodeError(err) && err.code === 'ENOENT') {\n      fileExists = false;\n      originalContent = '';\n    } else {\n      // File exists but could not be read (permissions, etc.)\n      fileExists = true; // Mark as existing but problematic\n      originalContent = ''; // Can't use its content\n      const error = {\n        message: getErrorMessage(err),","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/tools/write-file.ts#L157-L193","documentation":"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'.","triggerScenarios":"resolvedPath computed successfully -> validationError = config.validatePathAccess(resolvedPath) -> truthy -> return { error:{ message: validationError, code:'EACCES' } } at line 175.","commonSituations":"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.","solutions":["Move the target file under config.getTargetDir() / an allowed path.","Extend config's allowed folders / folder trust settings to include the path.","If the path is correct, check the message from validatePathAccess for the specific rule that blocked it."],"exampleFix":"// before\n{ file_path: '/home/user/elsewhere/x.ts' }\n// after\n{ file_path: 'src/x.ts' }  // inside the trusted workspace root","handlingStrategy":"validation","validationCode":"// confirm access before invoking the write tool\nconst err = config.validatePathAccess(resolvedPath);\nif (err) { /* pick a path inside the trusted root */ }","typeGuard":"function isAccessError(res: unknown): boolean {\n  return typeof res === 'object' && res !== null && (res as any).error?.code === 'EACCES';\n}","tryCatchPattern":"const res = await getCorrectedFileContent(config, filePath, content, signal);\nif (res.error?.code === 'EACCES') { return toolResultError('Path not allowed: ' + res.error.message); }","preventionTips":["Keep tool writes inside config.getTargetDir().","Extend folder trust explicitly when a new root is needed."],"tags":["permissions","eacces","path-validation","typescript"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}