{"record":{"id":"720622b4de230478","repo":"cloudflare/cloudflared","slug":"error-determining-install-path-720622","errorCode":null,"errorMessage":"error determining install path","messagePattern":"error determining install path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/macos_service.go","lineNumber":232,"sourceCode":"\tlog.Info().Msgf(\"Outputs are logged to %s and %s\", stderrPath, stdoutPath)\n\terr = runCommand(\"launchctl\", \"load\", plistPath)\n\tif err == nil {\n\t\tlog.Info().Msg(\"MacOS service for cloudflared installed successfully\")\n\t}\n\treturn err\n}\n\nfunc uninstallLaunchd(c *cli.Context) error {\n\tlog := logger.CreateLoggerFromContext(c, logger.EnableTerminalLog)\n\n\tif isRootUser() {\n\t\tlog.Info().Msg(\"Uninstalling cloudflared as a system launch daemon\")\n\t} else {\n\t\tlog.Info().Msg(\"Uninstalling cloudflared as a user launch agent\")\n\t}\n\tinstallPath, err := installPath()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"error determining install path\")\n\t}\n\tstdoutPath, err := stdoutPath()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"error determining stdout path\")\n\t}\n\tstderrPath, err := stderrPath()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"error determining stderr path\")\n\t}\n\tlaunchdTemplate := newLaunchdTemplate(installPath, stdoutPath, stderrPath)\n\tplistPath, err := launchdTemplate.ResolvePath()\n\tif err != nil {\n\t\tlog.Err(err).Msg(\"error resolving launchd template path\")\n\t\treturn err\n\t}\n\terr = runCommand(\"launchctl\", \"unload\", plistPath)\n\tif err != nil {\n\t\tlog.Err(err).Msg(\"error unloading launchd\")","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/macos_service.go#L214-L250","documentation":"Wrapped by uninstallLaunchd when it fails to compute the installed plist path (needed to rebuild the template and resolve its location before removing the service). installPath() uses resolveLibraryPath, so this is almost always the homedir.Dir() failure to find the user's home directory, meaning cloudflared cannot tell which plist file to uninstall.","triggerScenarios":"`cloudflared service uninstall` on macOS when installPath() -> homedir.Dir() errors: $HOME unset/wrong under sudo, no home directory for the user, OS lookup failure.","commonSituations":"Uninstalling from a script that scrubbed the environment; running as a different user than the one who installed; corrupted user records after account migration.","solutions":["Run the uninstall with a valid HOME, e.g. `sudo -H cloudflared service uninstall`.","Run as the same user who installed (or as root, which targets /Library/LaunchDaemons).","Fix the user's home directory entry via Directory Services.","Manually remove the plist as a last resort: `sudo launchctl bootout system/com.cloudflare.cloudflared; sudo rm /Library/LaunchDaemons/com.cloudflare.cloudflared.plist`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"[ -n \"${HOME:-}\" ] && [ -d \"$HOME\" ] || { echo \"HOME required for user-level uninstall\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"determining install path\") { tryManualPlistRemoval() }","preventionTips":["Uninstall as the same user (or root) that installed the service","Keep a fallback: sudo launchctl bootout + rm of the plist","Validate HOME in uninstall scripts","Document root vs per-user install targets for operators"],"tags":["macos","launchd","uninstall","home-directory"],"backgroundTag":"missing-env-var","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}