{"record":{"id":"7c9217a6ff403a82","repo":"charmbracelet/glow","slug":"unable-to-write-config-file-w","errorCode":null,"errorMessage":"unable to write config file: %w","messagePattern":"unable to write config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config_cmd.go","lineNumber":82,"sourceCode":"\tif ext := path.Ext(configFile); ext != \".yaml\" && ext != \".yml\" {\n\t\treturn fmt.Errorf(\"'%s' is not a supported configuration type: use '%s' or '%s'\", ext, \".yaml\", \".yml\")\n\t}\n\n\tif _, err := os.Stat(configFile); errors.Is(err, fs.ErrNotExist) {\n\t\t// File doesn't exist yet, create all necessary directories and\n\t\t// write the default config file\n\t\tif err := os.MkdirAll(filepath.Dir(configFile), 0o700); err != nil {\n\t\t\treturn fmt.Errorf(\"unable create directory: %w\", err)\n\t\t}\n\n\t\tf, err := os.Create(configFile)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to create config file: %w\", err)\n\t\t}\n\t\tdefer func() { _ = f.Close() }()\n\n\t\tif _, err := f.WriteString(defaultConfig); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to write config file: %w\", err)\n\t\t}\n\t} else if err != nil { // some other error occurred\n\t\treturn fmt.Errorf(\"unable to stat config file: %w\", err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":64,"sourceCodeEnd":89,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/config_cmd.go#L64-L89","documentation":"The final step of first-run config creation: the freshly created file (kept open with a deferred Close) is filled with defaultConfig via f.WriteString. This error wraps a short or failed write. Creation succeeded, so this is about writing bytes to the open file.","triggerScenarios":"Disk full or quota exceeded between os.Create and the write; filesystem I/O error (NFS stale handle, dying disk); the file being made read-only by a concurrent process or ACL between create and write; sandboxing blocking writes to the config area.","commonSituations":"Full home partitions on shared machines; container layers with size limits (overlay quota); security software locking newly created files; flaky network mounts.","solutions":["Check space: df -h ~/.config and quotas: quota -s","Retry the command — transient NFS/I/O hiccups often clear","Free space or point --config at a volume with room","Verify no security agent is holding/locking the file (lsof <configFile>)"],"exampleFix":"# before\n$ glow config\n# Error: unable to write config file: write /home/u/.config/glow/glow.yml: no space left on device\n\n# after\n$ df -h /home && rm -rf ~/.cache/tmp-big-files && glow config","handlingStrategy":"try-catch","validationCode":"// fail fast when the target volume has no room for the ~1KB default config\nvar stat syscall.Statfs_t\nif err := syscall.Statfs(filepath.Dir(configFile), &stat); err == nil {\n\tif stat.Bavail*uint64(stat.Bsize) < 64<<10 {\n\t\treturn errors.New(\"less than 64KiB free for the config volume\")\n\t}\n}","typeGuard":null,"tryCatchPattern":"if _, err := f.WriteString(defaultConfig); err != nil {\n\t// surface ENOSPC distinctly — the file was created but is incomplete\n\tif errors.Is(err, syscall.ENOSPC) {\n\t\t_ = f.Close()\n\t\t_ = os.Remove(configFile) // avoid leaving a truncated config behind\n\t\treturn fmt.Errorf(\"disk full while writing config; freed space? rerun 'glow config': %w\", err)\n\t}\n\treturn fmt.Errorf(\"unable to write config file: %w\", err)\n}","preventionTips":["Monitor free space on the home/config volume; glow will leave a truncated file on ENOSPC","Keep container overlay quotas comfortably above a few MB so first-run writes succeed","After any failed first run, delete the partial config before retrying"],"tags":["config","filesystem","disk-full","io"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}