shadcn-ui/ui · error · Error

Missing cached source for ${base.name}/${file.path}

Error message

Missing cached source for ${base.name}/${file.path}

What it means

During the per-file styled transform, the build looks up each registry file's original source in an in-memory Map (sourceFiles) keyed by file.path and populated earlier by reading registry/bases/<base>/<path>. If a registry item references a path that is not a key in that map — because the file could not be collected/read or the path differs — source is undefined and the build throws 'Missing cached source for <base>/<path>'.

Source

Thrown at apps/v4/scripts/build-registry.mts:1099

      await rimraf(styleOutputDir)
      await fs.mkdir(styleOutputDir, { recursive: true })

      const styleRegistry = { ...baseRegistry, items: registryItems }
      const registryTs = `export const registry = ${JSON.stringify(styleRegistry, null, 2)}\n`
      await fs.writeFile(path.join(styleOutputDir, "registry.ts"), registryTs)

      const filesToBuild = registryItems.flatMap((registryItem) =>
        normalizeRegistryFiles(registryItem)
      )

      await runWithConcurrency(
        filesToBuild,
        FILE_BUILD_CONCURRENCY,
        async (file) => {
          const source = sourceFiles.get(file.path)
          if (typeof source !== "string") {
            throw new Error(
              `Missing cached source for ${base.name}/${file.path}`
            )
          }

          const fileExtension = path.extname(file.path)
          const shouldTransform =
            fileExtension === ".tsx" || fileExtension === ".ts"

          const transformedContent = shouldTransform
            ? await getCachedStyledContent({
                styleName,
                baseName: base.name,
                filePath: file.path,
                source,
                styleHash,
                transformCacheHash,
                styleMap,
              })

View on GitHub (pinned to efac598707)

Solutions

  1. Confirm every file.path in the base registry items exists at registry/bases/<base>/<file.path>.
  2. Fix filename casing to match the registry exactly (case-sensitive).
  3. Remove registry items that reference deleted/orphan files.

Example fix

// registry/bases/radix/registry.ts before
{ name: "foo", type: "registry:ui", files: ["ui/foo.tsx"] } // ui/foo.tsx missing on disk

// after: create the file, or fix the path
{ name: "foo", type: "registry:ui", files: ["ui/button.tsx"] }
Defensive patterns

Strategy: validation

Validate before calling

import { promises as fs } from "fs"
import path from "path"
for (const item of registryItems) {
  for (const f of normalizeRegistryFiles(item)) {
    const abs = path.join(process.cwd(), `registry/bases/${base.name}/${f.path}`)
    await fs.access(abs) // throws ENOENT if missing — surfaces the bad path early
  }
}

Type guard

async function fileExists(p: string): Promise<boolean> {
  try { await fs.access(p); return true } catch { return false }
}

Prevention

When it happens

Trigger: A registry item lists a file path that does not exist under registry/bases/<base>/; path casing mismatch on a case-sensitive filesystem; a file deleted/renamed between the source-load phase and the transform phase; a registry item pointing at a file in another base.

Common situations: Adding a registry item before creating the component file; renaming a .tsx without updating registry.ts; developing on macOS (case-insensitive) then building on Linux CI.

Related errors


AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12). Data as JSON: /api/errors/b9425a177cd40e85. Report an issue: GitHub.