{"record":{"id":"17c0699c44470e38","repo":"apache/answer","slug":"write-file-failed-s","errorCode":null,"errorMessage":"write file failed %s","messagePattern":"write file failed (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/install.go","lineNumber":62,"sourceCode":"\t\tconfigFilePath = filepath.Join(path.ConfigFileDir, path.DefaultConfigFileName)\n\t}\n\tfmt.Println(\"[config-file] try to create at \", configFilePath)\n\n\t// if config file already exists do nothing.\n\tif CheckConfigFile(configFilePath) {\n\t\tfmt.Printf(\"[config-file] %s already exists\\n\", configFilePath)\n\t\treturn nil\n\t}\n\n\tif err := dir.CreateDirIfNotExist(path.ConfigFileDir); err != nil {\n\t\tfmt.Printf(\"[config-file] create directory fail %s\\n\", err.Error())\n\t\treturn fmt.Errorf(\"create directory fail %s\", err.Error())\n\t}\n\tfmt.Printf(\"[config-file] create directory success, config file is %s\\n\", configFilePath)\n\n\tif err := writer.WriteFile(configFilePath, string(configs.Config)); err != nil {\n\t\tfmt.Printf(\"[config-file] install fail %s\\n\", err.Error())\n\t\treturn fmt.Errorf(\"write file failed %s\", err)\n\t}\n\tfmt.Printf(\"[config-file] install success\\n\")\n\treturn nil\n}\n\nfunc installUploadDir() {\n\tfmt.Println(\"[upload-dir] try to install...\")\n\tif err := dir.CreateDirIfNotExist(path.UploadFilePath); err != nil {\n\t\tfmt.Printf(\"[upload-dir] install fail %s\\n\", err.Error())\n\t} else {\n\t\tfmt.Printf(\"[upload-dir] install success, upload directory is %s\\n\", path.UploadFilePath)\n\t}\n}\n\nfunc InstallI18nBundle(replace bool) {\n\tfmt.Println(\"[i18n] try to install i18n bundle...\")\n\t// if SKIP_REPLACE_I18N is set, skip replace i18n bundles\n\tif len(os.Getenv(\"SKIP_REPLACE_I18N\")) > 0 {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/cli/install.go#L44-L80","documentation":"InstallConfigFile returns this when writer.WriteFile fails to write the embedded config template to configFilePath after the directory was created successfully. The config file cannot be materialized, so environment init fails.","triggerScenarios":"writer.WriteFile(configFilePath, string(configs.Config)) errors due to permissions, disk full, or the target path being an existing directory.","commonSituations":"Disk quota exhausted, config path exists as a directory, antivirus/SELinux blocking file creation, read-only mount.","solutions":["Check write permissions on the config directory.","Free disk space / verify quota.","Ensure configFilePath does not already exist as a directory."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if err := os.Chmod(path.ConfigFileDir, 0o755); err != nil {\n    return fmt.Errorf(\"config dir not writable: %w\", err)\n}\n// check disk space\nif st, err := os.Statfs(path.ConfigFileDir); err == nil && st.Bavail == 0 {\n    return fmt.Errorf(\"no free space\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Monitor disk usage/quota","Don't place a directory where the config file goes","Exclude data dirs from restrictive security software"],"tags":["filesystem","permissions","disk"],"backgroundTag":"file-write-failed","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}