{"record":{"id":"5fba48b714c29d05","repo":"tauri-apps/tauri","slug":"path-is-not-a-directory","errorCode":null,"errorMessage":"'${path}' is not a directory.","messagePattern":"'(.+?)' is not a directory\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/api/rollup.config.ts","lineNumber":104,"sourceCode":"    writeBundle() {\n      // copy necessary files like `CHANGELOG.md` , `README.md` and Licenses to `./dist`\n      fg.sync('(LICENSE*|*.md|package.json)').forEach((f) =>\n        copyFileSync(f, `dist/${f}`)\n      )\n    }\n  }\n}\n\nfunction cleanDir(path: string) {\n  let dir: Dir\n  try {\n    dir = opendirSync(path)\n  } catch (err: any) {\n    switch (err.code) {\n      case 'ENOENT':\n        return // Noop when directory don't exists.\n      case 'ENOTDIR':\n        throw new Error(`'${path}' is not a directory.`)\n      default:\n        throw err\n    }\n  }\n\n  let file = dir.readSync()\n  while (file) {\n    const filePath = join(path, file.name)\n    rmSync(filePath, { recursive: true })\n    file = dir.readSync()\n  }\n  dir.closeSync()\n}\n","sourceCodeStart":86,"sourceCodeEnd":118,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/packages/api/rollup.config.ts#L86-L118","documentation":"Rollup's cleanDir helper opens a directory with opendirSync before unlinking its contents. ENOENT is treated as a no-op (nothing to clean), but ENOTDIR means the given path exists and is a file (or other non-directory), so cleaning would be meaningless and the build aborts with this error.","triggerScenarios":"The cleanDir() function in packages/api/rollup.config.ts is called with a path that resolves to an existing regular file or symlink-to-file instead of a directory (e.g. a stale artifact, or outputDir pointing at a file).","commonSituations":"A previous build wrote a file where a directory was expected; someone replaced the dist/output directory with a file; a misconfigured output path in rollup.config.ts; a symlink pointing to a file rather than a directory.","solutions":["Remove or rename the file currently occupying the path that should be a directory","Verify the output path passed to cleanDir is the intended directory and does not point at a file","Re-run the build; if a tool keeps recreating a file there, fix that tool's output config"],"exampleFix":"// before\nrm -f dist\n// after\nrm -rf dist  # ensure the path is a directory (or absent), not a plain file","handlingStrategy":"validation","validationCode":"import { statSync } from 'node:fs';\nfunction assertIsDirectoryOrAbsent(p: string) {\n  try { if (!statSync(p).isDirectory()) throw new Error(`${p} is not a directory`); }\n  catch (e: any) { if (e.code !== 'ENOENT') throw e; }\n}","typeGuard":"function isDirectory(p: string): boolean {\n  try { return statSync(p).isDirectory(); } catch { return false; }\n}","tryCatchPattern":"try { cleanDir(outputPath); } catch (err: any) {\n  if (err.message.includes('is not a directory')) {\n    rmSync(outputPath); cleanDir(outputPath); // remove offending file and retry\n  } else throw err;\n}","preventionTips":["Keep build output paths dedicated to directories only","Stat the output path before cleaning in build scripts","Watch for symlinks that resolve to files"],"tags":["filesystem","build","rollup","nodejs"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}