{"record":{"id":"944d423678ba86b4","repo":"remotion-dev/remotion","slug":"the-public-directory-was-specified-as-p-and","errorCode":null,"errorMessage":"The public directory was specified as \"${p}\", and while this path exists on the filesystem, it is not a directory.","messagePattern":"The public directory was specified as \"(.+?)\", and while this path exists on the filesystem, it is not a directory\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bundler/src/validate-public-dir.ts","lineNumber":16,"sourceCode":"import fs from 'node:fs';\nimport path from 'node:path';\n\nexport const validatePublicDir = (p: string) => {\n\tconst {root} = path.parse(process.cwd());\n\n\tif (p === root) {\n\t\tthrow new Error(\n\t\t\t`The public directory was specified as \"${p}\", which is the root directory. This is not allowed.`,\n\t\t);\n\t}\n\n\ttry {\n\t\tconst stat = fs.lstatSync(p);\n\t\tif (!stat.isDirectory()) {\n\t\t\tthrow new Error(\n\t\t\t\t`The public directory was specified as \"${p}\", and while this path exists on the filesystem, it is not a directory.`,\n\t\t\t);\n\t\t}\n\t} catch {\n\t\t// Path does not exist\n\t\t// Check if the parent path exists\n\t\tconst parentPath = path.dirname(p);\n\t\tconst exists = fs.existsSync(parentPath);\n\t\tif (!exists) {\n\t\t\tthrow new Error(\n\t\t\t\t`The public directory was specified as \"${p}\", but this folder does not exist and the parent directory \"${parentPath}\" does also not exist. Create at least the parent directory.`,\n\t\t\t);\n\t\t}\n\t}\n};\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/bundler/src/validate-public-dir.ts#L1-L32","documentation":"validatePublicDir stats the configured path; if it exists but lstatSync says it is not a directory (i.e. it is a file, symlink to a file, or special file), it throws. The public folder must be an actual directory.","triggerScenarios":"Config.publicDir pointing at a file path (e.g. './public.txt') or a symlink that resolves to a file rather than a directory.","commonSituations":"Typo in the path; the chosen name is already taken by a file; a symlink intended to point at a directory points at a file instead.","solutions":["Point publicDir at an actual directory.","If a file is occupying the name, remove or rename it and create a directory there.","If using a symlink, ensure it targets a directory."],"exampleFix":"// before\nConfig.setPublicDir('./public.json'); // a file\n\n// after\nConfig.setPublicDir('./public'); // a directory","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nconst assertPublicDirIsDirectory = (publicDir: string) => {\n  const stat = fs.lstatSync(publicDir); // throws if missing — see error 54\n  if (!stat.isDirectory()) {\n    throw new Error(`${publicDir} exists but is not a directory`);\n  }\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve the publicDir path for a directory; do not let a file occupy it.","If you symlink the public dir, target a directory.","Add a preflight check in CI that validates the public dir is a directory."],"tags":["bundler","public-dir","config","filesystem"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}