{"record":{"id":"d9f3cfceadeef0a7","repo":"withastro/astro","slug":"the-base-directory-fileurltopath-basedir-doe","errorCode":null,"errorMessage":"The base directory \"${fileURLToPath(baseDir)}\" does not exist.","messagePattern":"The base directory \"(.+?)\" does not exist\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/content/loaders/glob.ts","lineNumber":283,"sourceCode":"\t\t\tlet baseDir: URL;\n\t\t\tif (isLegacy && !globOptions.base) {\n\t\t\t\tbaseDir = new URL(`./src/content/${collection}`, config.root);\n\t\t\t} else {\n\t\t\t\tbaseDir = globOptions.base ? new URL(globOptions.base, config.root) : config.root;\n\t\t\t}\n\n\t\t\tif (!baseDir.pathname.endsWith('/')) {\n\t\t\t\tbaseDir.pathname = `${baseDir.pathname}/`;\n\t\t\t}\n\n\t\t\tconst filePath = fileURLToPath(baseDir);\n\t\t\tconst relativePath = relative(fileURLToPath(config.root), filePath);\n\n\t\t\tconst exists = existsSync(baseDir);\n\n\t\t\tif (!exists) {\n\t\t\t\t// We warn and don't return because we will still set up the watcher in case the directory is created later\n\t\t\t\tlogger.warn(`The base directory \"${fileURLToPath(baseDir)}\" does not exist.`);\n\t\t\t}\n\n\t\t\tconst files = await tinyglobby(globOptions.pattern, {\n\t\t\t\tcwd: fileURLToPath(baseDir),\n\t\t\t\texpandDirectories: false,\n\t\t\t});\n\n\t\t\tif (exists && files.length === 0) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t`No files found matching \"${globOptions.pattern}\" in directory \"${relativePath}\"`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction configForFile(file: string) {\n\t\t\t\tconst ext = file.split('.').at(-1);\n\t\t\t\tif (!ext) {\n\t\t\t\t\tlogger.warn(`No extension found for ${file}`);\n\t\t\t\t\treturn;","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/content/loaders/glob.ts#L265-L301","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst blog = defineCollection({ loader: glob({ pattern: '**/*.md', base: './src/data/blg' }) });\n\n// after\nconst blog = defineCollection({ loader: glob({ pattern: '**/*.md', base: './src/data/blog' }) });","handlingStrategy":"validation","validationCode":"// In content.config.ts, fail fast when the loader's base is missing\nimport { existsSync } from 'node:fs';\nif (!existsSync('./src/data/blog')) {\n  throw new Error('Missing content directory src/data/blog — create it (and commit a placeholder) before building');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["astro","content-collections","glob-loader","directory","filesystem"],"backgroundTag":"missing-content-directory","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}