{"record":{"id":"c25c3a649f0bb15e","repo":"shadcn-ui/ui","slug":"file-not-found-migratepath","errorCode":null,"errorMessage":"File not found: ${migratePath}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/migrations/cn/files.ts","lineNumber":40,"sourceCode":"]\n\nexport async function resolveMigrationFiles(cwd: string, migratePath?: string) {\n  if (!migratePath) {\n    return findSourceFiles(cwd)\n  }\n\n  if (migratePath.includes(\"*\")) {\n    const files = await findSourceFiles(cwd, migratePath)\n    if (!files.length) {\n      throw new Error(`No files found matching: ${migratePath}`)\n    }\n    return files\n  }\n\n  const resolvedPath = path.resolve(cwd, migratePath)\n  const stat = await fs.stat(resolvedPath).catch(() => null)\n  if (!stat) {\n    throw new Error(`File not found: ${migratePath}`)\n  }\n\n  if (stat.isFile()) {\n    return [resolvedPath]\n  }\n\n  if (stat.isDirectory()) {\n    const files = await findSourceFiles(resolvedPath)\n    if (!files.length) {\n      throw new Error(`No files found matching: ${migratePath}`)\n    }\n    return files\n  }\n\n  throw new Error(`Unsupported path type: ${migratePath}`)\n}\n\nfunction findSourceFiles(cwd: string, pattern = SOURCE_PATTERN) {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/shadcn-ui/ui/blob/5c7072da672b0048bc6771e3204063a2537df91a/packages/shadcn/src/migrations/cn/files.ts#L22-L58","documentation":"When migrateCn receives a non-glob `path`, resolveMigrationFiles resolves it against cwd and stats it with fs.stat. If the path does not exist on disk (stat resolves to null), the CLI throws `File not found: ${migratePath}` instead of proceeding. It applies to both file and directory inputs.","triggerScenarios":"migrateCn({ cwd, path: 'src/lib/utils.ts' }) where the file was renamed/deleted, or path 'src/lib' where the directory does not exist; also a mistyped relative path or a path outside the cwd that was never created.","commonSituations":"Typos in the path (`src/lib/utills.ts`), moving utils during a refactor, running from the wrong working directory, casing mismatches on case-sensitive filesystems (Linux), passing an absolute path that belongs to another machine/container.","solutions":["Correct the path passed via --path to an existing file or directory relative to the project root.","Run `ls <path>` from the same cwd the CLI uses to confirm the path exists.","Check case sensitivity of the path on Linux/CI environments.","Omit --path entirely to migrate all source files discovered from the project root."],"exampleFix":"// before\nawait migrateCn({ cwd: process.cwd(), path: 'src/lib/utills.ts' })\n// after\nawait migrateCn({ cwd: process.cwd(), path: 'src/lib/utils.ts' })","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs'\nimport { resolve } from 'path'\nconst p = resolve(process.cwd(), 'src/lib/utils.ts')\nif (!existsSync(p)) throw new Error(`Path does not exist: ${p}`)\nawait migrateCn({ cwd: process.cwd(), path: 'src/lib/utils.ts' })","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the path exists from the same cwd the CLI runs in.","Watch out for case-sensitive filesystems in CI/Linux.","Omit --path when you want whole-project discovery."],"tags":["filesystem","path","cli"],"backgroundTag":"file-not-found","analyzedSha":"5c7072da672b0048bc6771e3204063a2537df91a","analyzedAt":"2026-09-07T00:08:47.579Z","contentChangedAt":"2026-09-07T00:08:47.579Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}