{"record":{"id":"d2819be33c79e1d4","repo":"air-verse/air","slug":"failed-to-write-to-s-w","errorCode":null,"errorMessage":"failed to write to %s: %w","messagePattern":"failed to write to (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runner/config.go","lineNumber":372,"sourceCode":"\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}\n\n\treturn dftTOML, nil\n}\n\n// defaultPathConfig loads `.air.toml` or `.config/air.toml` when present.\n// The bool is true when a config file was loaded, false when defaults are returned.\nfunc defaultPathConfig() (*Config, bool, error) {\n\t// when path is blank, first find `.air.toml` in `air_wd` and current working directory or .config/air.toml, if not found, use defaults\n\tfor _, name := range []string{dftTOML, cfgTOML} {\n\t\tcfg, err := readConfByName(name)\n\t\tif err == nil {\n\t\t\treturn cfg, true, nil\n\t\t}\n\t\t// If the config file exists but failed to parse, report the error\n\t\t// Only use defaults if no config file exists\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn nil, false, fmt.Errorf(\"failed to parse %s: %w\", name, err)","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/air-verse/air/blob/71ea1dee05248122ed22b5870c7fb20a90d80ddd/runner/config.go#L354-L390","documentation":"After marshaling, writeDefaultConfig writes the schema header plus config content to the created file; a failed file.Write is wrapped as 'failed to write to %s' with the path (.air.toml) and cause. Disk full, I/O errors, or a closed/invalid handle typically trigger it.","triggerScenarios":"file.Write failing during `air init` — disk quota exceeded, ENOSPC, I/O error on a flaky mount, or the file handle becoming invalid.","commonSituations":"Full disks or quota-limited containers; writing onto a network/EFS mount that dropped; running out of inodes.","solutions":["Free disk space / check quota: `df -h .`","Retry air init after fixing storage","Check the wrapped cause (%w) for the exact errno and address the mount/filesystem"],"exampleFix":"// before\nair init  # failed to write to .air.toml: no space left on device\n// after\ndf -h .\n# free space, then\nair init","handlingStrategy":"retry","validationCode":"# ensure free space before writing .air.toml\n[ \"$(df --output=avail -k . | tail -1)\" -gt 1024 ] || echo \"low disk space\"","typeGuard":null,"tryCatchPattern":"if _, err := air.Init(); err != nil {\n    if strings.Contains(err.Error(), \"failed to write to\") {\n        // inspect the wrapped cause (ENOSPC, EIO, quota)\n        log.Fatalf(\"write failed: %v\", errors.Unwrap(err))\n        // fix storage, then retry air init\n    }\n}","preventionTips":["Monitor free disk space in dev containers","Avoid running air init on flaky network mounts","Check filesystem quotas before generating files"],"tags":["config","filesystem","io","init"],"backgroundTag":"disk-full-write-failed","analyzedSha":"71ea1dee05248122ed22b5870c7fb20a90d80ddd","analyzedAt":"2026-08-31T20:27:54.676Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}