{"record":{"id":"18d4bc8bce1ad91a","repo":"FuelLabs/fuels-ts","slug":"config-file-already-exists","errorCode":"CONFIG_FILE_ALREADY_EXISTS","errorMessage":"Config file exists, aborting.\n  ${fuelsConfigPath}","messagePattern":"Config file exists, aborting\\.\n  (.+?)","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"warning","filePath":"packages/fuels/src/cli/commands/init/index.ts","lineNumber":85,"sourceCode":"    const message = ['error: unable to detect program/s'];\n    if (contractLength === 0) {\n      message.push(`- contract/s detected ${contractLength}`);\n    }\n    if (scriptLength === 0) {\n      message.push(`- script/s detected ${scriptLength}`);\n    }\n    if (predicateLength === 0) {\n      message.push(`- predicate/s detected ${predicateLength}`);\n    }\n\n    log(message.join('\\r\\n'));\n    process.exit(1);\n  }\n\n  const fuelsConfigPath = join(path, 'fuels.config.ts');\n\n  if (existsSync(fuelsConfigPath)) {\n    throw new FuelError(\n      FuelError.CODES.CONFIG_FILE_ALREADY_EXISTS,\n      `Config file exists, aborting.\\n  ${fuelsConfigPath}`\n    );\n  }\n\n  const renderedConfig = renderFuelsConfigTemplate({\n    workspace,\n    contracts,\n    scripts,\n    predicates,\n    output,\n    forcPath,\n    fuelCorePath,\n    autoStartFuelCore,\n    fuelCorePort,\n  });\n\n  writeFileSync(fuelsConfigPath, renderedConfig);","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/fuels/src/cli/commands/init/index.ts#L67-L103","documentation":"Thrown by `fuels init` when fuels.config.ts already exists in the target directory. init is a scaffolding command meant to run once; the guard prevents overwriting an existing, possibly hand-edited config.","triggerScenarios":"Running `fuels init` a second time, or running it in a project that already went through scaffolding.","commonSituations":"Re-running a setup script, bootstrapping into an existing repo, CI that calls init on every run without checking.","solutions":["Stop using init — edit the existing fuels.config.ts directly.","Delete or rename the existing fuels.config.ts if you genuinely want to regenerate it.","Guard CI with a check: only run init when the config is absent."],"exampleFix":"// before\nfuels init   # config already present\n// after — skip if present\nif [ ! -f fuels.config.ts ]; then fuels init; fi","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nimport { join } from 'path';\nconst configExists = (dir: string): boolean => existsSync(join(dir, 'fuels.config.ts'));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make `fuels init` idempotent in CI: skip when fuels.config.ts exists.","Treat init as a one-time scaffold; edit the config thereafter.","Track fuels.config.ts in git so re-running init is unnecessary."],"tags":["cli","config","init","scaffolding"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}