{"record":{"id":"3b3ab04d32af9ac3","repo":"shadcn-ui/ui","slug":"we-could-not-find-a-valid-ui-path-in-your-compo","errorCode":null,"errorMessage":"We could not find a valid `ui` path in your `components.json` file. Please ensure you have a valid `ui` path in your `components.json` file.","messagePattern":"We could not find a valid `ui` path in your `components\\.json` file\\. Please ensure you have a valid `ui` path in your `components\\.json` file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/migrations/migrate-icons.ts","lineNumber":107,"sourceCode":"        basePath = fullPath\n        files = await fg(\"**/*.{js,ts,jsx,tsx}\", {\n          cwd: basePath,\n          onlyFiles: true,\n          ignore: [\"**/node_modules/**\"],\n        })\n      } else if (stat.isFile()) {\n        files = [options.path]\n      } else {\n        throw new Error(`Unsupported path type: ${options.path}`)\n      }\n    }\n\n    if (files.length === 0) {\n      throw new Error(`No files found matching: ${options.path}`)\n    }\n  } else {\n    if (!config.resolvedPaths.ui) {\n      throw new Error(\n        \"We could not find a valid `ui` path in your `components.json` file. Please ensure you have a valid `ui` path in your `components.json` file.\"\n      )\n    }\n\n    basePath = config.resolvedPaths.ui\n    files = await fg(\"**/*.{js,ts,jsx,tsx}\", {\n      cwd: basePath,\n    })\n  }\n\n  const registryIcons = await getRegistryIcons()\n\n  if (Object.keys(registryIcons).length === 0) {\n    throw new Error(\"Something went wrong fetching the registry icons.\")\n  }\n\n  const libraryChoices = Object.entries(MIGRATION_ICON_LIBRARIES).map(\n    ([name, iconLibrary]) => ({","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/migrations/migrate-icons.ts#L89-L125","documentation":"Thrown by migrateIcons when no --path was given AND config.resolvedPaths.ui is falsy. Without a user path the migrator falls back to scanning the configured `ui` directory, so an absent ui path leaves nothing to scan. The message points the user at components.json as the source of truth for that path.","triggerScenarios":"Invoking `shadcn migrate icons` (no --path) on a project whose components.json has no `aliases.ui` or where the alias resolves to an empty/undefined string. Also occurs when a custom partial Config object is passed programmatically without a resolved `ui` path.","commonSituations":"components.json was hand-edited and the `aliases.ui` field was deleted; the project uses a non-standard layout and `init` was never run; programmatic callers construct a Config literal and forget resolvedPaths.ui.","solutions":["Open components.json and confirm `aliases.ui` is set (e.g. \"@/components/ui\").","Re-run `npx shadcn@latest init` to regenerate a valid components.json with all aliases.","If calling migrateIcons programmatically, ensure the Config passed in has resolvedPaths.ui populated by get-config before invocation.","Alternatively, always pass `--path` to bypass the ui-path fallback entirely."],"exampleFix":"// before — components.json missing aliases.ui\n{\n  \"$schema\": \"https://ui.shadcn.com/schema.json\",\n  \"style\": \"new-york\",\n  \"rsc\": true,\n  \"aliases\": { \"components\": \"@/components\" }\n}\n\n// after\n{\n  \"$schema\": \"https://ui.shadcn.com/schema/json\",\n  \"style\": \"new-york\",\n  \"rsc\": true,\n  \"aliases\": { \"components\": \"@/components\", \"ui\": \"@/components/ui\" }\n}","handlingStrategy":"validation","validationCode":"function assertUiPath(config: Config) {\n  if (!config.resolvedPaths.ui) {\n    throw new Error(\n      'components.json is missing aliases.ui. Run `npx shadcn@latest init` or pass --path.'\n    )\n  }\n}\n\n// before calling migrateIcons without a path:\nassertUiPath(config)","typeGuard":"function hasUiPath(c: Partial<Config>): c is Config & { resolvedPaths: { ui: string } } {\n  return Boolean(c.resolvedPaths && typeof c.resolvedPaths.ui === 'string' && c.resolvedPaths.ui.length > 0)\n}","tryCatchPattern":"try {\n  await migrateIcons(config)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('valid `ui` path')) {\n    // fall back to an explicit path or run init\n    await migrateIcons(config, { path: './src/components/ui' })\n  } else throw e\n}","preventionTips":["Keep components.json under source control and review edits to `aliases`.","Run `shadcn init` after major project restructuring.","Programmatic callers should resolve Config via get-config, not construct literals."],"tags":["migration","icons","config","components-json","path-resolution"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}