{"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":"validation","errorClass":"GitNexusRcError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/analyze-config.ts","lineNumber":368,"sourceCode":"  }\n\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  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  return parseAnalyzeConfig(raw);\n}\n\n/** Load `.gitnexusrc` through the strict bounded reader used by watch mode. */\nexport async function loadAnalyzeConfigStrict(\n  repoRoot: string,\n): Promise<Partial<AnalyzeOptions> | undefined> {\n  let raw: string | null;\n  try {\n    raw = await readRepoControlFile(repoRoot, GITNEXUS_RC_FILENAME);\n  } catch (err) {\n    throw new GitNexusRcError(`Could not read ${GITNEXUS_RC_FILENAME}: ${(err as Error).message}`);\n  }\n  return raw === null ? undefined : parseAnalyzeConfig(raw);\n}\n","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/cli/analyze-config.ts#L350-L386","documentation":"loadAnalyzeConfig could not read .gitnexusrc for a reason other than 'file does not exist' (ENOENT returns undefined — no config is the normal case). Typical causes surfaced through the wrapped message: EACCES (permission denied), EISDIR (the path is a directory), or EMFILE/ENFILE (fd exhaustion). The underlying Node error message is appended.","triggerScenarios":"chmod 000 .gitnexusrc or ownership mismatch under root-vs-user runs; .gitnexusrc accidentally created as a directory; read-only container filesystems; too many open files in long-lived processes.","commonSituations":"Running analyze in Docker as a different uid than the file owner; sudo-created .gitnexusrc later read by a normal user; CI cache restoring the path as a directory; security tooling locking the file.","solutions":["Inspect the file: ls -la .gitnexusrc and stat it — the appended Node message tells you the exact code (EACCES vs EISDIR)","Fix permissions/ownership: chmod 644 .gitnexusrc (or chown to the running user)","If it is a directory, remove it and recreate as a regular JSON file","In containers, ensure the volume mount and run uid can read the repo root"],"exampleFix":"# before\n$ ls -la .gitnexusrc  # -rw------- root root\n# after\n$ sudo chown $(id -u):$(id -g) .gitnexusrc && chmod 644 .gitnexusrc","handlingStrategy":"try-catch","validationCode":"import { accessSync, constants } from 'node:fs';\ntry {\n  accessSync('.gitnexusrc', constants.R_OK);\n} catch {\n  console.error('.gitnexusrc is not readable by this uid — fix ownership/permissions');\n}","typeGuard":null,"tryCatchPattern":"try {\n  loadAnalyzeConfig(repoRoot);\n} catch (err) {\n  if (err instanceof GitNexusRcError && err.message.includes('Could not read')) {\n    const code = (err as NodeJS.ErrnoException).code;\n    if (code === 'EACCES') { /* chmod/chown the file */ }\n    if (code === 'EISDIR') { /* it is a directory — recreate as a file */ }\n  }\n}","preventionTips":["Create .gitnexusrc as the same user that runs analyze (avoid sudo-created root-owned files)","In Docker, ensure the run uid owns or can read repo-root files","Treat non-ENOENT read failures as environment problems, not config-syntax problems"],"tags":["config","filesystem","permissions","gitnexusrc"],"backgroundTag":"file-permission-denied","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-01T13:15:02.810Z","contentChangedAt":"2026-09-01T13:15:02.810Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}