{"record":{"id":"0d53da685bf2e1fe","repo":"JanDeDobbeleer/oh-my-posh","slug":"we-do-not-have-permissions-to-update","errorCode":null,"errorMessage":"we do not have permissions to update","messagePattern":"we do not have permissions to update","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/upgrade/install.go","lineNumber":33,"sourceCode":"// the running executable. It is exported because the terminal UI in\n// cli/upgrade/tui drives it directly; this package has no UI of its own.\nfunc Install(cfg *Config) error {\n\tsetState(StageValidating)\n\n\texecutable, err := os.Executable()\n\tif err != nil {\n\t\tlog.Debug(\"failed to get executable path\")\n\t\treturn err\n\t}\n\n\ttargetDir := filepath.Dir(executable)\n\tfileName := filepath.Base(executable)\n\n\tnewPath := filepath.Join(targetDir, fmt.Sprintf(\".%s.new\", fileName))\n\tfp, err := os.OpenFile(newPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0775)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn errors.New(\"we do not have permissions to update\")\n\t}\n\n\tsetState(StageDownloading)\n\n\tdata, err := downloadAndVerify(cfg)\n\tif err != nil {\n\t\tlog.Debug(\"failed to download and verify\")\n\t\treturn err\n\t}\n\n\tsetState(StageInstalling)\n\n\t_, err = io.Copy(fp, bytes.NewReader(data))\n\t// windows will have a lock when we do not close the file\n\tfp.Close()\n\n\tif err != nil {\n\t\tlog.Debug(\"failed to copy data to new file\")","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/upgrade/install.go#L15-L51","documentation":"The upgrade flow starts by creating the staging file `.<name>.new` inside the target directory (os.OpenFile with O_CREATE|O_WRONLY|O_TRUNC). If that open fails — typically a permissions problem — the upgrade aborts before downloading anything and returns this generic permissions message. The underlying OS error is logged, not included in the returned error.","triggerScenarios":"Running the self-upgrade (Install, called from Run) where the targetDir is not writable by the current user: oh-my-posh installed via package manager/root into a system path while running as a normal user, read-only filesystem, or directory owned by another account.","commonSituations":"Installed with brew/apt/sudo so the binary directory is root-owned; running in CI containers with read-only /usr/local/bin; Windows Program Files-style protected directories; disk-full or quota situations.","solutions":["Re-run the upgrade with elevated privileges (sudo/admin) matching how oh-my-posh was installed.","Check ownership/permissions of the directory containing the oh-my-posh executable (ls -l $(which oh-my-posh)).","If installed via a package manager, upgrade through that package manager instead of the self-upgrader.","Move the installation to a user-writable location and reinstall there, then self-upgrade normally.","Check for read-only mounts or disk/quota issues if the directory looks writable."],"exampleFix":"// before (fails when binary is root-owned)\noh-my-posh upgrade\n// after\nsudo oh-my-posh upgrade  # or: brew upgrade oh-my-posh / apt upgrade","handlingStrategy":"validation","validationCode":"exe, _ := os.Executable()\ndir := filepath.Dir(exe)\ntest := filepath.Join(dir, \".write-test\")\nif err := os.WriteFile(test, nil, 0o644); err != nil {\n    return fmt.Errorf(\"cannot write to %s; run with elevated privileges or use your package manager to upgrade\", dir)\n}\nos.Remove(test)","typeGuard":null,"tryCatchPattern":"if err := upgrade.Run(cfg); err != nil {\n    if strings.Contains(err.Error(), \"we do not have permissions to update\") {\n        fmt.Fprintln(os.Stderr, \"binary directory is not writable; try sudo/admin or upgrade via your package manager\")\n        os.Exit(1)\n    }\n    return err\n}","preventionTips":["Install oh-my-posh in a user-writable location if you plan to use self-upgrade","When the binary came from a package manager or root install, upgrade through that channel instead","Pre-check write access to the executable's directory in automation before triggering self-upgrade"],"tags":["permissions","filesystem","upgrade","cli"],"backgroundTag":"permission-denied","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}