FuelLabs/fuels-ts · warning · FuelError

CONFIG_FILE_ALREADY_EXISTS

CONFIG_FILE_ALREADY_EXISTS

Error message

Config file exists, aborting.
  ${fuelsConfigPath}

What it means

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.

Source

Thrown at packages/fuels/src/cli/commands/init/index.ts:85

    const message = ['error: unable to detect program/s'];
    if (contractLength === 0) {
      message.push(`- contract/s detected ${contractLength}`);
    }
    if (scriptLength === 0) {
      message.push(`- script/s detected ${scriptLength}`);
    }
    if (predicateLength === 0) {
      message.push(`- predicate/s detected ${predicateLength}`);
    }

    log(message.join('\r\n'));
    process.exit(1);
  }

  const fuelsConfigPath = join(path, 'fuels.config.ts');

  if (existsSync(fuelsConfigPath)) {
    throw new FuelError(
      FuelError.CODES.CONFIG_FILE_ALREADY_EXISTS,
      `Config file exists, aborting.\n  ${fuelsConfigPath}`
    );
  }

  const renderedConfig = renderFuelsConfigTemplate({
    workspace,
    contracts,
    scripts,
    predicates,
    output,
    forcPath,
    fuelCorePath,
    autoStartFuelCore,
    fuelCorePort,
  });

  writeFileSync(fuelsConfigPath, renderedConfig);

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Stop using init — edit the existing fuels.config.ts directly.
  2. Delete or rename the existing fuels.config.ts if you genuinely want to regenerate it.
  3. Guard CI with a check: only run init when the config is absent.

Example fix

// before
fuels init   # config already present
// after — skip if present
if [ ! -f fuels.config.ts ]; then fuels init; fi
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'fs';
import { join } from 'path';
const configExists = (dir: string): boolean => existsSync(join(dir, 'fuels.config.ts'));

Prevention

When it happens

Trigger: Running `fuels init` a second time, or running it in a project that already went through scaffolding.

Common situations: Re-running a setup script, bootstrapping into an existing repo, CI that calls init on every run without checking.

Related errors


AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12). Data as JSON: /api/errors/18d4bc8bce1ad91a. Report an issue: GitHub.