{"record":{"id":"19922ebb61f2854a","repo":"air-verse/air","slug":"failed-to-create-a-new-configuration-w","errorCode":null,"errorMessage":"failed to create a new configuration: %w","messagePattern":"failed to create a new configuration: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runner/config.go","lineNumber":355,"sourceCode":"\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...)\n\n\t_, err = file.Write(content)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to write to %s: %w\", dftTOML, err)\n\t}","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/air-verse/air/blob/71ea1dee05248122ed22b5870c7fb20a90d80ddd/runner/config.go#L337-L373","documentation":"After confirming `.air.toml` does not exist, writeDefaultConfig creates it with os.Create; if creation fails (permission, read-only filesystem, path is a directory), the error is wrapped as 'failed to create a new configuration'. The underlying cause is preserved via %w.","triggerScenarios":"Running `air init` where a directory named `.air.toml` exists, the working directory is read-only, or the user lacks write permission.","commonSituations":"CI containers with read-only source mounts; running air init inside a directory where `.air.toml` is a directory; disk full.","solutions":["Ensure the directory is writable: chmod/chown or move to another directory","Check that `.air.toml` is not a directory: `ls -la .air.toml`","Check disk space with `df -h`"],"exampleFix":"// before\nair init  # failed to create a new configuration: is a directory\n// after\nrm -rf .air.toml   # remove the stray directory\nair init","handlingStrategy":"validation","validationCode":"# ensure no .air.toml exists and the dir is writable before init\n[ -e .air.toml ] && echo \".air.toml already exists\"\n[ -w . ] || echo \"directory not writable\"","typeGuard":null,"tryCatchPattern":"if _, err := air.Init(); err != nil {\n    if strings.Contains(err.Error(), \"failed to create a new configuration\") {\n        log.Fatalf(\"cannot create .air.toml here: %v\", errors.Unwrap(err))\n    }\n}","preventionTips":["Confirm the working directory is writable before air init","Check .air.toml is not an existing directory","Ensure adequate disk space and no read-only mounts"],"tags":["config","filesystem","permissions","init"],"backgroundTag":"file-permission-denied","analyzedSha":"71ea1dee05248122ed22b5870c7fb20a90d80ddd","analyzedAt":"2026-08-31T20:27:54.676Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}