{"record":{"id":"ea0f63f44b4c98b2","repo":"JanDeDobbeleer/oh-my-posh","slug":"unable-to-write-font-file-s","errorCode":null,"errorMessage":"unable to write font file: %s","messagePattern":"unable to write font file: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/font/install_windows.go","lineNumber":53,"sourceCode":"\t\t}\n\t}\n\n\tlog.Debug(\"fonts directory exists, proceeding with installation\")\n\n\tfullPath := filepath.Join(fontsDir, font.FileName)\n\t// validate if the font is already installed, remove it in case it is\n\tif _, err := os.Stat(fullPath); err == nil {\n\t\tlog.Debugf(\"font %s already exists, removing it\", fullPath)\n\t\tif err = os.Remove(fullPath); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to remove existing font file: %s\", err.Error())\n\t\t}\n\t}\n\n\tlog.Debugf(\"writing font file to %s\", fullPath)\n\n\terr := os.WriteFile(fullPath, font.Data, 0644)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to write font file: %s\", err.Error())\n\t}\n\n\tlog.Debug(\"font file written successfully, proceeding with registry entry\")\n\n\t// Add registry entry\n\treg := registry.CURRENT_USER\n\tregValue := fullPath\n\n\tlog.Debug(\"opening HKEY_CURRENT_USER for writing (SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Fonts)\")\n\n\tk, _, err := registry.CreateKey(reg, `SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts`, registry.WRITE)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\t// If this fails, remove the font file as well.\n\t\tif nexterr := os.Remove(fullPath); nexterr != nil {\n\t\t\tlog.Error(nexterr)\n\t\t\treturn errors.New(\"unable to delete font file after registry key open error\")\n\t\t}","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/font/install_windows.go#L35-L71","documentation":"The Windows installer writes the font bytes to `fontsDir\\font.FileName` with `os.WriteFile(..., 0644)` and wraps any write failure with this message. At this point the directory exists and any old file was removed, so failures are almost always permission, disk-space, or AV-interference issues.","triggerScenarios":"`os.WriteFile(fullPath, font.Data, 0644)` returns an error during `install` on Windows: access denied writing to C:\\Windows\\Fonts non-elevated, ERROR_DISK_FULL, or the just-removed file handle is still open by another process preventing recreation.","commonSituations":"Non-elevated shell attempting machine-wide install; full system drive; antivirus quarantine/race on newly created font files; another process re-created/locked the target path between Stat and WriteFile.","solutions":["Run the terminal as Administrator for a machine-wide install, or use the default per-user install path (no elevation)","Free disk space on the drive holding the fonts directory","Temporarily exclude the fonts directory from real-time AV scanning and retry","Retry — a transient file lock may have cleared","Manually verify you can create a file in the fonts dir (`New-Item test.txt`) to confirm write access"],"exampleFix":"// before: non-elevated\nPS> oh-my-posh font install FiraCode   # unable to write font file\n// after\nPS (admin)> oh-my-posh font install FiraCode","handlingStrategy":"validation","validationCode":"# confirm write access and disk space first\n$dir = \"$env:LOCALAPPDATA\\Microsoft\\Windows\\Fonts\"\ntry { [IO.File]::WriteAllText(\"$dir\\.wtest\", \"x\"); Remove-Item \"$dir\\.wtest\" }\ncatch { Write-Error \"No write access to $dir\"; exit 1 }\nif ((Get-PSDrive ($dir[0]) ).Free -lt 50MB) { Write-Error 'Low disk space'; exit 1 }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify write access to the fonts directory before batch installs","Keep free disk space on the system drive","Exclude the fonts directory from real-time AV scanning during installs"],"tags":["windows","filesystem","permissions"],"backgroundTag":"file-write-permission-denied","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}