{"record":{"id":"7bd67d692f2bfb5f","repo":"remix-run/react-router","slug":"file-collisions-detected-in-a-non-interactive-envi","errorCode":null,"errorMessage":"File collisions detected in a non-interactive environment","messagePattern":"File collisions detected in a non-interactive environment","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/create-react-router/index.ts","lineNumber":393,"sourceCode":"        lines.push(`and ${moreFiles} more...`);\n      }\n      return lines.join(`\\n${prefix}`);\n    };\n\n    if (ctx.overwrite) {\n      info(\n        \"Overwrite:\",\n        `overwriting files due to \\`--overwrite\\`:${getFileList(\"           \")}`,\n      );\n    } else if (!ctx.interactive) {\n      error(\n        \"Oh no!\",\n        `Destination directory contains files that would be overwritten\\n` +\n          `         and no \\`--overwrite\\` flag was included in a non-interactive\\n` +\n          `         environment. The following files would be overwritten:` +\n          getFileList(\"           \"),\n      );\n      throw new Error(\n        \"File collisions detected in a non-interactive environment\",\n      );\n    } else {\n      if (ctx.debug) {\n        debug(`Colliding files:${getFileList(\"          \")}`);\n      }\n\n      let { overwrite } = await ctx.prompt({\n        name: \"overwrite\",\n        type: \"confirm\",\n        label: title(\"overwrite\"),\n        message:\n          `Your project directory contains files that will be overwritten by\\n` +\n          `             this template (you can force with \\`--overwrite\\`)\\n\\n` +\n          `             Files that would be overwritten:` +\n          `${getFileList(\"               \")}\\n\\n` +\n          `             Do you wish to continue?\\n` +\n          `             `,","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/remix-run/react-router/blob/1fd704a7dabcbe3ae09d7387b460e6acaba30ec1/packages/create-react-router/index.ts#L375-L411","documentation":"Thrown in copyTempDirToAppDirStep() when the destination project directory already contains files that would be overwritten by the template AND the shell is non-interactive AND --overwrite was not passed. In non-interactive mode there is no way to prompt, so the CLI refuses to destroy existing files. The colliding filenames (up to 5, plus an 'and N more' line) are listed in the preceding error() output.","triggerScenarios":"Running create-react-router ./existing-dir --yes in CI where ./existing-dir already has files; targeting '.' (current dir) which contains a README or package.json; re-running the scaffolder into a previously partially-created project without --overwrite.","commonSituations":"CI that re-runs into the same workspace; initializing into a git repo that already has files; pointing cwd at a non-empty directory by mistake; running the command twice.","solutions":["Pass --overwrite to allow clobbering existing files in non-interactive mode.","Choose an empty or non-existent target directory.","Move/delete the conflicting files out of the destination first.","Inspect the listed collisions in the error output and decide which to keep before re-running with --overwrite."],"exampleFix":"// before\ncreate-react-router ./my-app --yes   # my-app already has files\n// after\ncreate-react-router ./my-app --yes --overwrite\n# or target a fresh directory:\ncreate-react-router ./my-app-2 --yes","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\nfunction isDirEmptyOrMissing(dir: string): boolean {\n  if (!fs.existsSync(dir)) return true;\n  return fs.readdirSync(dir).length === 0;\n}\n// Non-interactive wrapper:\nif (!isInteractiveStdin() && !isDirEmptyOrMissing(projectDir)) {\n  throw new Error('Destination not empty; pass --overwrite or pick a fresh dir');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In CI, target empty directories or pass --overwrite deliberately.","Pre-check destination contents before scaffolding.","Use unique per-run directories to avoid collisions.","Never point create-react-router at a version-controlled working tree without --overwrite."],"tags":["cli","filesystem","overwrite","non-interactive","create-react-router"],"backgroundTag":null,"analyzedSha":"1fd704a7dabcbe3ae09d7387b460e6acaba30ec1","analyzedAt":"2026-08-12T13:54:57.804Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}