shadcn-ui/ui · error · Error

Failed to fetch components from registry.

Error message

Failed to fetch components from registry.

What it means

Thrown by the dry-run pipeline (dryRun) when resolveRegistryTree(components, config) returns a falsy value. Identical root cause to the add-path error but in the read-only dry-run flow: the registry tree could not be resolved, so there is nothing to preview.

Source

Thrown at packages/shadcn/src/utils/dry-run.ts:100

  const result: DryRunResult = {
    files: [],
    dependencies: [],
    devDependencies: [],
    css: null,
    envVars: null,
    fonts: [],
    docs: null,
  }

  if (!components.length) {
    return result
  }

  // Resolve the registry tree (read-only).
  let tree = await resolveRegistryTree(components, configWithDefaults(config))

  if (!tree) {
    throw new Error("Failed to fetch components from registry.")
  }

  // Massage tree for fonts (read-only).
  if (!options.skipFonts) {
    tree = await massageTreeForFonts(tree, config)
  }
  const supportedFontMarkers = getSupportedFontMarkers([tree])

  // Dependencies pass through deduplicated.
  result.dependencies = Array.from(new Set(tree.dependencies ?? []))
  result.devDependencies = Array.from(new Set(tree.devDependencies ?? []))

  // Docs pass through directly.
  result.docs = tree.docs ?? null

  // Process files.
  await processFiles(tree, config, result, options, supportedFontMarkers)

View on GitHub (pinned to efac598707)

Solutions

  1. Confirm the registry URL/namespace resolves and is reachable (curl the endpoint).
  2. Check the component names passed into the dry run.
  3. Provide any required auth/env so the registry returns a full tree.
  4. Retry once to rule out a transient network blip.

Example fix

# before
dryRun(['nonexistent-item'], config)
# after
dryRun(['button'], config)
curl -s https://your-registry.example.com/r/button.json
Defensive patterns

Strategy: retry

Validate before calling

const tree = await resolveRegistryTree(components, configWithDefaults(config))
if (!tree) throw new Error(`could not resolve tree for: ${components.join(", ")}`)

Type guard

const hasResolvedTree = (t: unknown): t is NonNullable<typeof t> =>
  !!t && typeof t === "object"

Try / catch

try {
  await dryRun(components, config)
} catch (e) {
  if (e instanceof Error && /Failed to fetch components/.test(e.message)) {
    // fall back to a local/cached registry or retry
  }
}

Prevention

When it happens

Trigger: Running a dry-run preview for a set of components where the registry fetch yields no tree. The check `if (!tree)` fires right after resolveRegistryTree and before font massaging and file processing.

Common situations: Network error or unreachable registry during preview; wrong component names; registry returning an empty/invalid tree payload; dry-running against a registry URL that requires auth that was not provided.

Related errors


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