shadcn-ui/ui · error · RegistrySourceFileError

FETCH_ERROR

FETCH_ERROR

Error message

Failed to read file "${filePath}" for registry item "${itemName}" (${formatItemSource(source)}). Expected file at ${sourcePath}.

What it means

Thrown by readRegistryItemFileContent when the underlying reader.readText(sourcePath) call for a registry item's declared file fails (file missing, FS permission, or a GitHub source-file error). The original error is wrapped in a RegistrySourceFileError with item name, source file, item index, and a suggestion. If the underlying error was already a GitHub-source-file RegistrySourceFileError, its suggestion is preserved; otherwise the generic 'path relative to registry.json' suggestion is used.

Source

Thrown at packages/shadcn/src/registry/source.ts:206

    ),
  }
}

async function readRegistryItemFileContent(
  itemName: string,
  filePath: string,
  sourcePath: string,
  source: RegistryItemSource | undefined,
  reader: RegistrySourceReader
) {
  try {
    return await reader.readText(sourcePath)
  } catch (error) {
    const isGitHubSourceFileError =
      error instanceof RegistrySourceFileError &&
      error.context?.reason === "github-source-file"

    throw new RegistrySourceFileError(sourcePath, error, {
      message: `Failed to read file "${filePath}" for registry item "${itemName}" (${formatItemSource(
        source
      )}). Expected file at ${sourcePath}.`,
      context: {
        registryFile: source?.registryFile,
        itemIndex: source?.itemIndex,
        itemName,
        itemFilePath: filePath,
        sourcePath,
      },
      suggestion:
        isGitHubSourceFileError && error.suggestion
          ? error.suggestion
          : "Make sure the file path is relative to the registry.json file that declares the item.",
    })
  }
}

View on GitHub (pinned to efac598707)

Solutions

  1. Confirm the file exists at `<registryDir>/<file.path>` relative to the registry.json that declares the item.
  2. Fix the `path` field in the item's files array to point at the actual file.
  3. For GitHub-backed readers, verify the ref and the blob path are correct (the preserved GitHub suggestion will be more specific).
Defensive patterns

Strategy: try-catch

Validate before calling

async function fileReadable(reader: RegistrySourceReader, sourcePath: string) {
  try {
    await reader.readText(sourcePath);
    return true;
  } catch {
    return false;
  }
}

Try / catch

import { RegistrySourceFileError } from "@/src/registry/errors";

try {
  await loadRegistryItemFromSource(name, reader, opts);
} catch (e) {
  if (e instanceof RegistrySourceFileError) {
    // e.context.itemFilePath and e.context.sourcePath identify the missing file
  }
  throw e;
}

Prevention

When it happens

Trigger: An item in source registry.json declares `files: [{ path: "./button.tsx" }]`, but no `button.tsx` exists at that path relative to the declaring registry.json's directory; or the GitHub reader cannot fetch the blob at the resolved ref+path.

Common situations: File path typo in the item declaration; file moved/deleted without updating the registry; on GitHub sources, wrong branch/tag/ref or the file lives in a different path; cross-platform path separator mistakes.

Related errors


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