slopus/happy · error

Daemon installation requires sudo privileges. Please run wit

Error message

Daemon installation requires sudo privileges. Please run with sudo.

What it means

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.

Source

Thrown at packages/happy-cli/src/daemon/install.ts:10

import { logger } from '@/ui/logger';
import { install as installMac } from './mac/install';

export async function install(): Promise<void> {
    if (process.platform !== 'darwin') {
        throw new Error('Daemon installation is currently only supported on macOS');
    }
    
    if (process.getuid && process.getuid() !== 0) {
        throw new Error('Daemon installation requires sudo privileges. Please run with sudo.');
    }
    
    logger.info('Installing Happy CLI daemon for macOS...');
    await installMac();
}

View on GitHub (pinned to b824cd0a46)

Solutions

  1. Re-run the command with sudo: `sudo happy daemon install`
  2. Verify elevation with `id -u` (should print 0) before installing
  3. If sudo is unavailable, run happy without the daemon instead
  4. Ensure the npm global prefix is writable if avoiding root entirely

Example fix

// before
happy daemon install
// after
sudo happy daemon install
Defensive patterns

Strategy: validation

Validate before calling

if (process.platform === 'darwin' && process.getuid && process.getuid() !== 0) {
  throw new Error('Re-run with sudo: sudo happy daemon install');
}

Try / catch

try {
  await install();
} catch (err) {
  if (err.message.includes('sudo privileges')) {
    console.error('Please run: sudo happy daemon install');
    process.exitCode = 1;
  } else throw err;
}

Prevention

When it happens

Trigger: Running `happy daemon install` on macOS without sudo — the command reaches the platform check (darwin passes) but fails the uid check.

Common situations: 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.

Related errors


AI-assisted analysis of slopus/happy@b824cd0a46 (2026-08-31). Data as JSON: /api/errors/7154cdf4c4be3a52. Report an issue: GitHub.