{"record":{"id":"9f3689326a8ac0b0","repo":"abhigyanpatwari/GitNexus","slug":"index-storage-path-is-not-a-directory-resolved","errorCode":null,"errorMessage":"Index storage path is not a directory: ${resolved}","messagePattern":"Index storage path is not a directory: (.+?)","errorType":"validation","errorClass":"InvalidStoragePathError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/storage/storage-resolver.ts","lineNumber":733,"sourceCode":"    : ['owned'];\n  if (!allowedStates.includes(inspection.state)) {\n    throw new StorageDeletionError(\n      expectedStoragePath,\n      actualStoragePath,\n      inspection,\n      `the storage inspection state is \"${inspection.state}\"`,\n    );\n  }\n  return actualStoragePath;\n};\n\n/** Ensure a selected index directory is usable before an analysis takes its lock. */\nexport const ensureStoragePathWritable = async (storagePath: string): Promise<void> => {\n  const resolved = validateConfiguredStoragePath(storagePath);\n  await fsp.mkdir(resolved, { recursive: true });\n  const stat = await fsp.stat(resolved);\n  if (!stat.isDirectory()) {\n    throw new InvalidStoragePathError(`Index storage path is not a directory: ${resolved}`);\n  }\n  await fsp.access(resolved, fs.constants.R_OK | fs.constants.W_OK);\n};\n","sourceCodeStart":715,"sourceCodeEnd":737,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/storage/storage-resolver.ts#L715-L737","documentation":"An InvalidStoragePathError from ensureStoragePathWritable, thrown after mkdir/stat when the configured storage path resolves to something that is not a directory (e.g. a regular file or symlink to a file). GitNexus requires the index storage location to be a real, writable directory before an analysis takes its lock.","triggerScenarios":"Running analyze (or any flow calling ensureStoragePathWritable) with GITNEXUS_STORAGE_PATH pointing at an existing regular file, or where mkdir recursive:true was a no-op because a file occupies the path.","commonSituations":"GITNEXUS_STORAGE_PATH accidentally set to a file (e.g. a tarball or log); a stale file left where a directory used to be; a symlink retargeted from a directory to a file; a mount point replaced by a file after a volume change.","solutions":["Remove or rename the file currently occupying the storage path so the directory can be created.","Correct GITNEXUS_STORAGE_PATH to point at a directory (or a path that does not yet exist and can be created).","Check for a stale symlink with `ls -la` and fix or remove it.","Re-run the command; the resolver will mkdir the directory and re-validate permissions."],"exampleFix":"// before\nGITNEXUS_STORAGE_PATH=/tmp/index.tar.gz npx gitnexus analyze\n// after\nrm /tmp/index.tar.gz && GITNEXUS_STORAGE_PATH=/tmp/myrepo-index npx gitnexus analyze","handlingStrategy":"try-catch","validationCode":"const st = await fsp.stat(storagePath).catch(() => null);\nif (st && !st.isDirectory()) {\n  throw new Error(`GITNEXUS_STORAGE_PATH points at a non-directory: ${storagePath}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ensureStoragePathWritable(storagePath);\n} catch (err) {\n  if (err instanceof InvalidStoragePathError && /not a directory/.test(err.message)) {\n    fs.rmSync(storagePath, { force: true }); // remove the offending file, then retry\n  } else throw err;\n}","preventionTips":["Check `ls -la` on GITNEXUS_STORAGE_PATH: it must be absent or a directory.","Don't point storage paths at files, tarballs, or logs.","Watch for symlinks retargeted from directories to files after volume changes.","Let GitNexus create the directory (mkdir recursive) rather than pre-creating it as a file."],"tags":["storage","filesystem","config"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}