remotion-dev/remotion · error · Error
The public directory was specified as "${p}", which is the r
Error message
The public directory was specified as "${p}", which is the root directory. This is not allowed. What it means
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.
Source
Thrown at packages/bundler/src/validate-public-dir.ts:8
import fs from 'node:fs';
import path from 'node:path';
export const validatePublicDir = (p: string) => {
const {root} = path.parse(process.cwd());
if (p === root) {
throw new Error(
`The public directory was specified as "${p}", which is the root directory. This is not allowed.`,
);
}
try {
const stat = fs.lstatSync(p);
if (!stat.isDirectory()) {
throw new Error(
`The public directory was specified as "${p}", and while this path exists on the filesystem, it is not a directory.`,
);
}
} catch {
// Path does not exist
// Check if the parent path exists
const parentPath = path.dirname(p);
const exists = fs.existsSync(parentPath);
if (!exists) {
throw new Error(View on GitHub (pinned to 78fe4bb3fd)
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.
Example fix
// before
Config.setPublicDir('/');
// after
Config.setPublicDir('public'); // or omit — defaults to ./public Defensive patterns
Strategy: validation
Validate before calling
import path from 'node:path';
const assertPublicDirNotRoot = (publicDir: string) => {
const {root} = path.parse(process.cwd());
if (publicDir === root) {
throw new Error(`publicDir must not be the filesystem root ("${root}")`);
}
}; Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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 '/'.
Related errors
- The public directory was specified as "${p}", and while this
- The public directory was specified as "${p}", but this folde
- Invalid public file path: ${path}
- setImageSequence accepts a Boolean Value
- outputLocation must be a string but got ${typeof newOutputLo
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/0b5017d678f0f568.
Report an issue: GitHub.