air-verse/air · error

configuration already exists

Error message

configuration already exists

What it means

`air init` (writeDefaultConfig) refuses to create a new `.air.toml` when one already exists in the current directory. It deliberately aborts instead of overwriting an existing configuration file, since regenerating would destroy user edits.

Source

Thrown at runner/config.go:350

		config.Overwrite = true
	})
	if err != nil {
		return nil, false, err
	}

	if err = applyPlatformOverrides(ret); err != nil {
		return nil, false, err
	}
	return ret, fromFile, nil
}

func writeDefaultConfig() (string, error) {
	fstat, err := os.Stat(dftTOML)
	if err != nil && !os.IsNotExist(err) {
		return "", fmt.Errorf("failed to check for existing configuration: %w", err)
	}
	if err == nil && fstat != nil {
		return "", errors.New("configuration already exists")
	}

	file, err := os.Create(dftTOML)
	if err != nil {
		return "", fmt.Errorf("failed to create a new configuration: %w", err)
	}
	defer file.Close()

	config := defaultConfigBase()
	setEntrypointFromBin(&config)
	addPlatformOverridesForInit(&config, runtime.GOOS)
	configFile, err := toml.Marshal(config)
	if err != nil {
		return "", fmt.Errorf("failed to marshal the default configuration: %w", err)
	}

	headers := []byte(schemaHeader + "\n\n")
	content := append(headers, configFile...)

View on GitHub (pinned to 71ea1dee05)

Solutions

  1. Just run `air` directly — the existing .air.toml will be used, no init needed
  2. Delete or rename the existing .air.toml if you truly want a fresh default: `mv .air.toml .air.toml.bak && air init`
  3. Edit the existing .air.toml instead of regenerating it

Example fix

// before
air init  # -> configuration already exists
// after
mv .air.toml .air.toml.bak
air init  # writes a fresh default config
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(".air.toml"); err == nil {
    // config already exists — run `air` directly or back it up before `air init`
}

Prevention

When it happens

Trigger: Running `air init` (which calls writeDefaultConfig) when `os.Stat(dftTOML)` succeeds, i.e. a `.air.toml` file already exists in the working directory.

Common situations: Re-running `air init` in a project that was already initialized; cloning a repo that ships a checked-in `.air.toml` and running init; being in the wrong directory where a stale `.air.toml` exists.

Related errors


AI-assisted analysis of air-verse/air@71ea1dee05 (2026-08-31). Data as JSON: /api/errors/d01beeccb69209d2. Report an issue: GitHub.