Skip to content

Support claudeCodePath in ~/.hapi/settings.json #596

@uxfion

Description

@uxfion

What feature would you like to see?

Add a persisted claudeCodePath field to ~/.hapi/settings.json, resolved by getDefaultClaudeCodePath() alongside the existing HAPI_CLAUDE_PATH env var.

Additional information

HAPI_CLAUDE_PATH is read from process.env, which is frozen at process startup. The runner is a long-lived daemon, so its env is fixed at the time it was first spawned — updating the variable in a shell after the fact never reaches it. This is the source of #425 and #229, and forces users to hapi runner stop + start + manually kill stale child sessions. Setting it once in shell rc avoids the issue, but switching binaries or onboarding mid-flow is awkward.

Proposal:

  1. Add claudeCodePath?: string to Settings in cli/src/persistence.ts.

  2. In getDefaultClaudeCodePath() (cli/src/claude/sdk/utils.ts), resolve in order env override → settings → PATH probe:

    export function getDefaultClaudeCodePath(): string {
      if (process.env.HAPI_CLAUDE_PATH) return process.env.HAPI_CLAUDE_PATH;
      const settings = readSettingsSync();
      if (settings.claudeCodePath) return settings.claudeCodePath;
      // existing PATH probing...
    }
  3. (Optional) hapi config set claude-path <path> for ergonomic writes.

Because getDefaultClaudeCodePath() runs per claude spawn (per user message in remote mode), settings.json is read fresh — switching binaries takes effect on the next message, no restart, no session kill. HAPI_CLAUDE_PATH stays as the highest-priority override for backward compat. The pattern extends naturally to future HAPI_*_PATH agents.

Happy to send a PR if the direction looks good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions