{"record":{"id":"3947f924ec3d1a30","repo":"JanDeDobbeleer/oh-my-posh","slug":"unable-to-create-fonts-directory-s","errorCode":null,"errorMessage":"unable to create fonts directory: %s","messagePattern":"unable to create fonts directory: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/font/install_windows.go","lineNumber":34,"sourceCode":"\nconst (\n\tWM_FONTCHANGE  = 0x001D\n\tHWND_BROADCAST = 0xFFFF\n)\n\nfunc install(font *Font) error {\n\t// To install a font on Windows:\n\t//  - Copy the file to the fonts directory\n\t//  - Add registry entry\n\t//  - Call AddFontResourceW to set the font\n\tfontsDir := filepath.Join(os.Getenv(\"USERPROFILE\"), \"AppData\", \"Local\", \"Microsoft\", \"Windows\", \"Fonts\")\n\n\tlog.Debugf(\"installing font %s to %s\", font.FileName, fontsDir)\n\n\t// check if the Fonts folder exists, if not, create it\n\tif _, err := os.Stat(fontsDir); os.IsNotExist(err) {\n\t\tif err = os.MkdirAll(fontsDir, 0755); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to create fonts directory: %s\", err.Error())\n\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 {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/font/install_windows.go#L16-L52","documentation":"On Windows, the font installer copies the font into the system/user fonts directory (`%LOCALAPPDATA%\\Microsoft\\Windows\\Fonts` or `C:\\Windows\\Fonts`). This error wraps the failure of `os.MkdirAll(fontsDir, 0755)` when the directory doesn't exist and cannot be created — usually a permissions problem, not a missing parent.","triggerScenarios":"`install` on Windows: `os.Stat(fontsDir)` reports IsNotExist, then `os.MkdirAll` fails (access denied writing to C:\\Windows\\Fonts without elevation, or the user profile path is unavailable/redirected).","commonSituations":"Running `oh-my-posh font install` in a non-elevated shell trying to write to C:\\Windows\\Fonts; roaming-profile or OneDrive-redirected LOCALAPPDATA; antivirus blocking directory creation; running under a service account with no profile.","solutions":["Run the terminal as Administrator if you intend a machine-wide install to C:\\Windows\\Fonts","Prefer the per-user font install (no elevation needed) — ensure LOCALAPPDATA resolves correctly (`echo %LOCALAPPDATA%`)","Check disk space and antivirus/EDR policies that block folder creation in Fonts","Create the fonts directory manually once with proper ACLs, then retry","Fix the user profile path if LOCALAPPDATA points to a nonexistent location"],"exampleFix":"// before: non-elevated attempt on machine fonts\nPS> oh-my-posh font install FiraCode   # unable to create fonts directory\n// after: elevated PowerShell\nPS (admin)> oh-my-posh font install FiraCode","handlingStrategy":"validation","validationCode":"# PowerShell pre-check before running the installer\n$fontsDir = \"$env:LOCALAPPDATA\\Microsoft\\Windows\\Fonts\"\nif (-not (Test-Path $fontsDir)) {\n  try { New-Item -ItemType Directory -Path $fontsDir -ErrorAction Stop | Out-Null }\n  catch { Write-Error \"Cannot create fonts dir: $_\"; exit 1 }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use per-user font installs (default) to avoid needing elevation for C:\\Windows\\Fonts","Ensure LOCALAPPDATA points to an existing, writable profile path","Check AV/EDR policies that block directory creation before automating installs"],"tags":["windows","filesystem","permissions"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}