{"record":{"id":"7154cdf4c4be3a52","repo":"slopus/happy","slug":"daemon-installation-requires-sudo-privileges-plea","errorCode":null,"errorMessage":"Daemon installation requires sudo privileges. Please run with sudo.","messagePattern":"Daemon installation requires sudo privileges\\. Please run with sudo\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/daemon/install.ts","lineNumber":10,"sourceCode":"import { logger } from '@/ui/logger';\nimport { install as installMac } from './mac/install';\n\nexport async function install(): Promise<void> {\n    if (process.platform !== 'darwin') {\n        throw new Error('Daemon installation is currently only supported on macOS');\n    }\n    \n    if (process.getuid && process.getuid() !== 0) {\n        throw new Error('Daemon installation requires sudo privileges. Please run with sudo.');\n    }\n    \n    logger.info('Installing Happy CLI daemon for macOS...');\n    await installMac();\n}","sourceCodeStart":1,"sourceCodeEnd":15,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/daemon/install.ts#L1-L15","documentation":"On macOS, install() additionally requires root; if process.getuid() !== 0 it throws, because installing the launchd daemon writes to system locations (/Library/LaunchDaemons) that need elevated privileges.","triggerScenarios":"Running `happy daemon install` on macOS without sudo — the command reaches the platform check (darwin passes) but fails the uid check.","commonSituations":"User runs the install command in a non-elevated terminal; npm-installed global binary invoked without sudo; script automation runs as a non-root CI user on a mac runner.","solutions":["Re-run the command with sudo: `sudo happy daemon install`","Verify elevation with `id -u` (should print 0) before installing","If sudo is unavailable, run happy without the daemon instead","Ensure the npm global prefix is writable if avoiding root entirely"],"exampleFix":"// before\nhappy daemon install\n// after\nsudo happy daemon install","handlingStrategy":"validation","validationCode":"if (process.platform === 'darwin' && process.getuid && process.getuid() !== 0) {\n  throw new Error('Re-run with sudo: sudo happy daemon install');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await install();\n} catch (err) {\n  if (err.message.includes('sudo privileges')) {\n    console.error('Please run: sudo happy daemon install');\n    process.exitCode = 1;\n  } else throw err;\n}","preventionTips":["Run daemon install with sudo on macOS","Check `id -u === 0` before installing system daemons","Document the sudo requirement in setup scripts","In automation, run install steps as root on mac runners"],"tags":["daemon","permissions","macos","sudo"],"backgroundTag":"root-privileges-required","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}