{"record":{"id":"d01beeccb69209d2","repo":"air-verse/air","slug":"configuration-already-exists","errorCode":null,"errorMessage":"configuration already exists","messagePattern":"configuration already exists","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runner/config.go","lineNumber":350,"sourceCode":"\t\tconfig.Overwrite = true\n\t})\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\n\tif err = applyPlatformOverrides(ret); err != nil {\n\t\treturn nil, false, err\n\t}\n\treturn ret, fromFile, nil\n}\n\nfunc writeDefaultConfig() (string, error) {\n\tfstat, err := os.Stat(dftTOML)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn \"\", fmt.Errorf(\"failed to check for existing configuration: %w\", err)\n\t}\n\tif err == nil && fstat != nil {\n\t\treturn \"\", errors.New(\"configuration already exists\")\n\t}\n\n\tfile, err := os.Create(dftTOML)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create a new configuration: %w\", err)\n\t}\n\tdefer file.Close()\n\n\tconfig := defaultConfigBase()\n\tsetEntrypointFromBin(&config)\n\taddPlatformOverridesForInit(&config, runtime.GOOS)\n\tconfigFile, err := toml.Marshal(config)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to marshal the default configuration: %w\", err)\n\t}\n\n\theaders := []byte(schemaHeader + \"\\n\\n\")\n\tcontent := append(headers, configFile...)","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/air-verse/air/blob/71ea1dee05248122ed22b5870c7fb20a90d80ddd/runner/config.go#L332-L368","documentation":"`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.","triggerScenarios":"Running `air init` (which calls writeDefaultConfig) when `os.Stat(dftTOML)` succeeds, i.e. a `.air.toml` file already exists in the working directory.","commonSituations":"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.","solutions":["Just run `air` directly — the existing .air.toml will be used, no init needed","Delete or rename the existing .air.toml if you truly want a fresh default: `mv .air.toml .air.toml.bak && air init`","Edit the existing .air.toml instead of regenerating it"],"exampleFix":"// before\nair init  # -> configuration already exists\n// after\nmv .air.toml .air.toml.bak\nair init  # writes a fresh default config","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(\".air.toml\"); err == nil {\n    // config already exists — run `air` directly or back it up before `air init`\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check for .air.toml before running air init","Never check a generated .air.toml into a repo where contributors run air init","Back up an existing config before regenerating"],"tags":["config","init","air","toml"],"backgroundTag":"config-file-already-exists","analyzedSha":"71ea1dee05248122ed22b5870c7fb20a90d80ddd","analyzedAt":"2026-08-31T20:27:54.676Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}