withastro/astro · warning
The base directory "${fileURLToPath(baseDir)}" does not exis
Error message
The base directory "${fileURLToPath(baseDir)}" does not exist. What it means
The glob() loader's base directory (the `base` option, defaulted to the collection directory for legacy collections) does not exist on disk. Astro warns but deliberately does not return early: it still sets up the watcher so entries sync if the directory is created later; the glob itself simply matches nothing.
Source
Thrown at packages/astro/src/content/loaders/glob.ts:283
let baseDir: URL;
if (isLegacy && !globOptions.base) {
baseDir = new URL(`./src/content/${collection}`, config.root);
} else {
baseDir = globOptions.base ? new URL(globOptions.base, config.root) : config.root;
}
if (!baseDir.pathname.endsWith('/')) {
baseDir.pathname = `${baseDir.pathname}/`;
}
const filePath = fileURLToPath(baseDir);
const relativePath = relative(fileURLToPath(config.root), filePath);
const exists = existsSync(baseDir);
if (!exists) {
// We warn and don't return because we will still set up the watcher in case the directory is created later
logger.warn(`The base directory "${fileURLToPath(baseDir)}" does not exist.`);
}
const files = await tinyglobby(globOptions.pattern, {
cwd: fileURLToPath(baseDir),
expandDirectories: false,
});
if (exists && files.length === 0) {
logger.warn(
`No files found matching "${globOptions.pattern}" in directory "${relativePath}"`,
);
}
function configForFile(file: string) {
const ext = file.split('.').at(-1);
if (!ext) {
logger.warn(`No extension found for ${file}`);
return;View on GitHub (pinned to e294953aa8)
Solutions
- Create the directory (mkdir -p src/data/blog) or commit a placeholder file inside it so git keeps it
- Fix the base URL — it is resolved against the project root, so verify each relative segment
- If a later step creates the directory, the warning is harmless: the watcher picks the folder up once it exists
Example fix
// before
const blog = defineCollection({ loader: glob({ pattern: '**/*.md', base: './src/data/blg' }) });
// after
const blog = defineCollection({ loader: glob({ pattern: '**/*.md', base: './src/data/blog' }) }); Defensive patterns
Strategy: validation
Validate before calling
// In content.config.ts, fail fast when the loader's base is missing
import { existsSync } from 'node:fs';
if (!existsSync('./src/data/blog')) {
throw new Error('Missing content directory src/data/blog — create it (and commit a placeholder) before building');
} Prevention
- Commit a .gitkeep or placeholder entry so directories survive git checkouts
- Run content-generating scripts before astro build/dev in the pipeline
- Assert expected content directories exist in a pre-build check
When it happens
Trigger: glob({ base, pattern }) where base points at a directory that has not been created; a typo in the base URL path segments; content produced by a later pipeline step that has not run yet.
Common situations: Fresh clones before a content-generation step runs; renamed content folders; CI checkouts that drop empty directories; scripts that create the directory later in the build.
Related errors
- No contents found for ${entry}
- **${collection}** contains multiple entries with the same sl
- No extension found for ${file}
- The glob() loader cannot be used for files in ${colors.bold(
- Skipped the following files that matched ${colors.green(patt
AI-assisted analysis of withastro/astro@e294953aa8 (2026-08-18).
Data as JSON: /api/errors/d9f3cfceadeef0a7.
Report an issue: GitHub.