slopus/happy · error · Error

No machine ID found in settings

Error message

No machine ID found in settings

What it means

runAcp reads the local happy settings file and requires a machineId to register/identify the machine with the happy API (`api.getOrCreateMachine`). If settings are missing or lack machineId, it cannot identify this machine and throws. This is a data prerequisite, not a network failure.

Source

Thrown at packages/happy-cli/src/agent/acp/runAcp.ts:464

  return 'acp';
}

export async function runAcp(opts: {
  credentials: Credentials;
  agentName: string;
  command: string;
  args: string[];
  startedBy?: 'daemon' | 'terminal';
  verbose?: boolean;
}): Promise<void> {
  const verbose = opts.verbose === true;
  const sessionTag = randomUUID();
  connectionState.setBackend(opts.agentName);

  const api = await ApiClient.create(opts.credentials);
  const settings = await readSettings();
  if (!settings?.machineId) {
    throw new Error('No machine ID found in settings');
  }

  await api.getOrCreateMachine({
    machineId: settings.machineId,
    metadata: initialMachineMetadata,
  });

  const { state, metadata } = createSessionMetadata({
    flavor: resolveSessionFlavor(opts.agentName),
    machineId: settings.machineId,
    startedBy: opts.startedBy,
    sandbox: settings.sandboxConfig,
  });
  const response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
  if (response) {
    logAcp('muted', `Happy Session ID: ${response.id}`);
  }

View on GitHub (pinned to b824cd0a46)

Solutions

  1. Run the happy CLI's normal auth/setup flow once to create settings with machineId.
  2. Inspect the settings file location and confirm a non-empty machineId exists.
  3. Delete the corrupt settings file and re-authenticate to regenerate it.
  4. Ensure HOME/XDG paths are set correctly so readSettings finds the file (CI/containers).

Example fix

// before
$ npx happy-cli acp claude-code  // fresh box, no settings
// after
$ npx happy-cli auth   # writes settings including machineId
$ npx happy-cli acp claude-code
Defensive patterns

Strategy: validation

Validate before calling

import { readSettings } from '...';
const settings = await readSettings();
if (!settings?.machineId) {
  console.error('Run `happy` auth/setup first to create settings with a machineId');
  process.exit(1);
}

Type guard

function hasMachineId(s: unknown): s is { machineId: string } & Record<string, unknown> {
  return typeof s === 'object' && s !== null && 'machineId' in s &&
    typeof (s as { machineId?: unknown }).machineId === 'string' &&
    (s as { machineId: string }).machineId.length > 0;
}

Try / catch

try {
  await runAcp(opts);
} catch (err) {
  if (err instanceof Error && err.message === 'No machine ID found in settings') {
    console.error('No happy settings found. Authenticate with the happy CLI first.');
    process.exit(1);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling runAcp before ever running `happy` auth/setup that writes settings; a corrupted or reset ~/.happy settings file; settings.json present but machineId key absent (older schema).

Common situations: Fresh machine/container where the user never authenticated; CI environments without persisted settings; manually edited or truncated settings file; upgrading from a version that didn't store machineId.

Related errors


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