{"record":{"id":"8808c7ca7dba36b7","repo":"abhigyanpatwari/GitNexus","slug":"could-not-read-gitnexus-rc-filename-err-as","errorCode":null,"errorMessage":"Could not read ${GITNEXUS_RC_FILENAME}: ${(err as Error).message}","messagePattern":"Could not read (.+?): (.+?)","errorType":"exception","errorClass":"GitNexusRcError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/analyze-config.ts","lineNumber":379,"sourceCode":"\n  return out;\n};\n\n/**\n * Locate, read, parse, validate, and normalize `.gitnexusrc` at `repoRoot`.\n *\n * @returns the normalized config defaults, or `undefined` when no file exists\n *          (the normal case). Throws {@link GitNexusRcError} on any problem.\n */\nexport function loadAnalyzeConfig(repoRoot: string): Partial<AnalyzeOptions> | undefined {\n  const filePath = path.join(repoRoot, GITNEXUS_RC_FILENAME);\n\n  let raw: string;\n  try {\n    raw = fs.readFileSync(filePath, 'utf-8');\n  } catch (err) {\n    if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') return undefined;\n    throw new GitNexusRcError(`Could not read ${GITNEXUS_RC_FILENAME}: ${(err as Error).message}`);\n  }\n\n  // Strip a leading UTF-8 BOM: Node's 'utf-8' decode keeps it, and JSON.parse\n  // then fails with a confusing \"Unexpected token\" on an otherwise-valid file\n  // (#1996 tri-review). Only one leading BOM is stripped; in-string control\n  // rejection still applies to the parsed values.\n  if (raw.charCodeAt(0) === 0xfeff) raw = raw.slice(1);\n\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(raw);\n  } catch (err) {\n    throw new GitNexusRcError(\n      `${GITNEXUS_RC_FILENAME} is not valid JSON: ${(err as Error).message}. ` +\n        `Expected a JSON object such as {\"defaultBranch\": \"develop\", \"skipContextFiles\": true}.`,\n    );\n  }\n","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/cli/analyze-config.ts#L361-L397","documentation":"`.gitnexusrc` exists at the resolved repo root but `fs.readFileSync` failed for a reason other than ENOENT (file-not-found returns `undefined` silently, the normal no-config case). Typical causes are EACCES (permission denied), a broken symlink, or an I/O error on the mount. The original error message is appended.","triggerScenarios":"File mode 0000 or owned by another user (EACCES); `.gitnexusrc` is a dangling symlink; the repo root is on a read-only or failing mount.","commonSituations":"CI/Docker running as a different UID than the file owner; restricted bind-mounts; NFS permissions; a teammate committed a symlink by mistake.","solutions":["Check permissions and ownership: `ls -la .gitnexusrc` and ensure the running user can read it.","If it is a broken symlink, remove it: `rm .gitnexusrc` and recreate as a real file.","If unintended, delete the file so the normal no-config path applies.","On Docker/CI, set the file mode to 0644 or chown it to the container user."],"exampleFix":"# before (EACCES on mode 0600 owned by root)\n# after\nchmod 644 .gitnexusrc","handlingStrategy":"try-catch","validationCode":"import fs from 'node:fs';\ntry {\n  fs.accessSync('.gitnexusrc', fs.constants.R_OK);\n} catch (e) {\n  console.error('.gitnexusrc is not readable by this user');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const cfg = loadAnalyzeConfig(repoRoot);\n} catch (e) {\n  if (e instanceof GitNexusRcError && e.message.startsWith('Could not read')) {\n    cliError(e.message + ' — verify file permissions and ownership.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Ensure the CI/Docker user owns or can read .gitnexusrc (mode 0644).","Do not commit .gitnexusrc as a broken symlink."],"tags":["config","gitnexusrc","filesystem","permissions"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}