shadcn-ui/ui · error

Could not find a valid `ui` path in your `components.json`.

Error message

Could not find a valid `ui` path in your `components.json`. Please provide a path or glob pattern.

What it means

Thrown by migrateRtl when no --path was given and config.resolvedPaths.ui is falsy. Unlike the icons/radix variants, this message also suggests providing a path or glob pattern as an alternative to fixing components.json. Without a ui path or explicit path the RTL migrator has no file set.

Source

Thrown at packages/shadcn/src/migrations/migrate-rtl.ts:68

        files = await fg("**/*.{js,ts,jsx,tsx}", {
          cwd: basePath,
          onlyFiles: true,
          ignore: ["**/node_modules/**"],
        })
      } else if (stat.isFile()) {
        files = [options.path]
      } else {
        throw new Error(`Unsupported path type: ${options.path}`)
      }
    }

    if (files.length === 0) {
      throw new Error(`No files found matching: ${options.path}`)
    }
  } else {
    // Default: use ui path from components.json.
    if (!config.resolvedPaths.ui) {
      throw new Error(
        "Could not find a valid `ui` path in your `components.json`. Please provide a path or glob pattern."
      )
    }

    basePath = config.resolvedPaths.ui
    files = await fg("**/*.{js,ts,jsx,tsx}", {
      cwd: basePath,
      onlyFiles: true,
    })
  }

  // Confirm with user.
  if (!options.yes) {
    const relativePath = options.path
      ? options.path
      : `./${path.relative(config.resolvedPaths.cwd, basePath)}`

    const { confirm } = await prompts({

View on GitHub (pinned to efac598707)

Solutions

  1. Provide `--path` to bypass the ui-path fallback.
  2. Add `aliases.ui` to components.json.
  3. Re-run `npx shadcn@latest init`.
  4. Programmatic callers: resolve Config via get-config first.

Example fix

// before
shadcn migrate rtl
// (components.json has no aliases.ui)

// after — either pass a path
shadcn migrate rtl --path ./src/components/ui
// or add to components.json:
"aliases": { "components": "@/components", "ui": "@/components/ui" }
Defensive patterns

Strategy: validation

Validate before calling

function assertUiPathOrExplicit(config: Config, path?: string) {
  if (!path && !config.resolvedPaths.ui) {
    throw new Error('Provide --path or set aliases.ui in components.json before running RTL migration.')
  }
}

assertUiPathOrExplicit(config, options.path)

Type guard

function hasUiPath(c: Partial<Config>): c is Config & { resolvedPaths: { ui: string } } {
  return Boolean(c.resolvedPaths?.ui)
}

Try / catch

try {
  await migrateRtl(config)
} catch (e) {
  if (e instanceof Error && e.message.includes('valid `ui` path')) {
    await migrateRtl(config, { path: './src/components/ui' })
  } else throw e
}

Prevention

When it happens

Trigger: Running `shadcn migrate rtl` (no --path) on a project lacking `aliases.ui`; programmatic call with a Config missing resolvedPaths.ui.

Common situations: components.json missing the ui alias; project never initialized; partial programmatic Config.

Related errors


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