{"record":{"id":"cdb491b986af114f","repo":"air-verse/air","slug":"failed-to-check-for-existing-configuration-w","errorCode":null,"errorMessage":"failed to check for existing configuration: %w","messagePattern":"failed to check for existing configuration: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runner/config.go","lineNumber":347,"sourceCode":"\t\t// So need use this to avoid that none-zero slice will be overwritten.\n\t\t// https://dario.cat/mergo#transformers\n\t\tconfig.Transformers = sliceTransformer{}\n\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}","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/air-verse/air/blob/71ea1dee05248122ed22b5870c7fb20a90d80ddd/runner/config.go#L329-L365","documentation":"writeDefaultConfig first stats `.air.toml` to see whether a config exists; if Stat fails for a reason other than NotExist (e.g. permission denied on the directory), it returns this wrapped error instead of proceeding. It is distinct from the 'already exists' case — here the check itself failed.","triggerScenarios":"Running `air init` in a directory where statting `.air.toml` fails with EACCES/EIO — e.g. a parent directory without execute permission, or `.air.toml` being a broken path with odd permissions.","commonSituations":"Read-only or restricted working directories (containers, mounted volumes); a `.air.toml` symlink pointing somewhere inaccessible; SELinux/AppArmor denials.","solutions":["Check permissions on the current directory: `ls -ld .` and fix with chmod/chown","Inspect the wrapped error (%w) to see the exact syscall cause","Run in a writable directory or as a user with access"],"exampleFix":"// before\nair init  # failed to check for existing configuration: permission denied\n// after\nls -ld .\nchmod u+rwx .\nair init","handlingStrategy":"try-catch","validationCode":"# verify the working directory is readable before air init\nls -la . >/dev/null || echo \"cannot access directory\"","typeGuard":null,"tryCatchPattern":"if _, err := air.Init(); err != nil {\n    if strings.Contains(err.Error(), \"failed to check for existing configuration\") {\n        // stat failed — inspect unwrapped cause with errors.Unwrap\n        log.Fatalf(\"config stat failed: %v\", errors.Unwrap(err))\n    }\n}","preventionTips":["Run air init in a directory you own and can read","Watch for restricted mount points (containers, CI) that deny stat","Inspect the wrapped cause with errors.Unwrap for the exact syscall error"],"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"}