{"record":{"id":"0b5017d678f0f568","repo":"remotion-dev/remotion","slug":"the-public-directory-was-specified-as-p-whic","errorCode":null,"errorMessage":"The public directory was specified as \"${p}\", which is the root directory. This is not allowed.","messagePattern":"The public directory was specified as \"(.+?)\", which is the root directory\\. This is not allowed\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bundler/src/validate-public-dir.ts","lineNumber":8,"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(","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/bundler/src/validate-public-dir.ts#L1-L26","documentation":"validatePublicDir compares the configured public directory path against the filesystem root derived from process.cwd(). If they are equal (e.g. '/' on POSIX or 'C:\\' on Windows), it rejects, because exposing the entire drive root as the public (served) directory is a severe security and correctness hazard.","triggerScenarios":"Config.publicDir (or the CLI --public-dir) resolves to the filesystem root: setting it to '/', or to a path that the platform treats as root, or an empty string that resolves to root.","commonSituations":"Typo or env-driven misconfiguration that yields the root; copy-pasting a config that sets publicDir to an absolute root; CI where cwd-rooted math produces '/'.","solutions":["Set publicDir to a real subfolder, e.g. the default './public'.","If publicDir is computed from variables, validate it is not the root before applying.","Use a path relative to the project root and let Remotion resolve it."],"exampleFix":"// before\nConfig.setPublicDir('/');\n\n// after\nConfig.setPublicDir('public'); // or omit — defaults to ./public","handlingStrategy":"validation","validationCode":"import path from 'node:path';\nconst assertPublicDirNotRoot = (publicDir: string) => {\n  const {root} = path.parse(process.cwd());\n  if (publicDir === root) {\n    throw new Error(`publicDir must not be the filesystem root (\"${root}\")`);\n  }\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to './public' and only override with a real subfolder path.","When publicDir is computed from env/config, validate it is not the platform root before applying.","Prefer relative paths for publicDir.","Add a config sanity check in your setup script."],"tags":["bundler","public-dir","config","security","validation"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}