{"record":{"id":"d1b0ee1f5bd91a09","repo":"yamadashy/repomix","slug":"instruction-file-not-found-at-instructionpath","errorCode":null,"errorMessage":"Instruction file not found at ${instructionPath}","messagePattern":"Instruction file not found at (.+?)","errorType":"exception","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/core/output/outputGenerate.ts","lineNumber":334,"sourceCode":"  processedFiles: ProcessedFile[],\n  gitDiffResult: GitDiffResult | undefined = undefined,\n  gitLogResult: GitLogResult | undefined = undefined,\n  filePathsByRoot?: FilesByRoot[],\n  emptyDirPaths?: string[],\n  deps = {\n    listDirectories,\n    listFiles,\n    searchFiles,\n  },\n): Promise<OutputGeneratorContext> => {\n  let repositoryInstruction = '';\n\n  if (config.output.instructionFilePath) {\n    const instructionPath = path.resolve(config.cwd, config.output.instructionFilePath);\n    try {\n      repositoryInstruction = await fs.readFile(instructionPath, 'utf-8');\n    } catch {\n      throw new RepomixError(`Instruction file not found at ${instructionPath}`);\n    }\n  }\n\n  // Determine if full-tree mode applies (only when directory structure is rendered)\n  const shouldUseFullTree =\n    config.output.directoryStructure === true &&\n    !!config.output.includeFullDirectoryStructure &&\n    (config.include?.length ?? 0) > 0;\n\n  // Paths to include in the directory tree visualization\n  let directoryPathsForTree: string[] = [];\n  let filePathsForTree: string[] = allFilePaths;\n\n  // Only prefix with the per-root label for genuine multi-root packs. For a single\n  // root, filePathsByRoot still carries a basename fallback label, but pack() leaves\n  // single-root file paths unprefixed — so prefixing the full-tree directories here\n  // would desync them from the included files and add a spurious root branch.\n  const toOutputDisplayPath = (rootDir: string, filePath: string, index: number): string =>","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/core/output/outputGenerate.ts#L316-L352","documentation":"Repomix throws this when `config.output.instructionFilePath` is set but the file at that path (resolved against `config.cwd`) cannot be read — typically because it does not exist, though any read failure (permission, directory, bad encoding) hits the same catch. It wraps the silent fs failure into a user-facing RepomixError so CLI runs fail fast with a clear message instead of silently producing output without the custom instructions.","triggerScenarios":"Calling repomix pack (or the API's output generation, via outputGeneratorContext -> buildOutputGeneratorContext) with `output.instructionFilePath` pointing to a path that does not exist relative to `config.cwd`, or to an unreadable file.","commonSituations":"A relative path in repomix.json that resolves differently because cwd differs (e.g. running from a subdirectory or CI workspace root); a renamed/deleted custom-instructions.md; committing a config referencing a file gitignored on CI; typos like `intructions.md`.","solutions":["Verify the file exists at path.resolve(config.cwd, config.output.instructionFilePath) and create it if missing.","Fix the path in config (use an absolute path or one correct relative to the cwd repomix runs in).","Remove `output.instructionFilePath` from the config if custom instructions are not needed.","Check file read permissions if the file exists but is unreadable."],"exampleFix":"// before (repomix.json, run from repo root but file lives in docs/)\n\"instructionFilePath\": \"custom-instructions.md\"\n// after\n\"instructionFilePath\": \"docs/custom-instructions.md\"","handlingStrategy":"validation","validationCode":"import fs from 'node:fs/promises';\nimport path from 'node:path';\nconst p = path.resolve(config.cwd, config.output.instructionFilePath);\nawait fs.access(p, fs.constants.R_OK); // throws ENOENT before repomix runs","typeGuard":"null","tryCatchPattern":"try {\n  await pack(...);\n} catch (e) {\n  if (e instanceof RepomixError && e.message.startsWith('Instruction file not found')) {\n    console.error(`Check output.instructionFilePath (cwd=${config.cwd})`);\n  } else throw e;\n}","preventionTips":["Use paths relative to the repo root and run repomix from the repo root.","Commit the instruction file (don't gitignore it).","Add a startup check that asserts referenced config files exist.","Omit output.instructionFilePath when no custom instructions are needed."],"tags":["config","file-not-found","output"],"backgroundTag":"file-not-found","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}