fix: run Happy daemon as app user so it can find credentials #15

Merged
cpfarhood merged 1 commits from fix/happy-daemon-user into main 2026-02-20 15:01:06 +00:00
cpfarhood commented 2026-02-20 15:00:22 +00:00 (Migrated from github.com)

Summary

When init-repo.sh starts the Happy daemon it runs as root, so HOME=/root. Happy Coder and Claude Code look for credentials and config in ~/.happy and ~/.claude, which resolve to /root/... — not /home/user/... where the actual user credentials live.

This is why:

  • happy launched from a VSCode terminal works (runs as user, correct home dir)
  • The background daemon doesn't work (runs as root, wrong home dir, missing credentials)

The fix uses sudo -u <user> -E so the daemon runs as the correct user while still inheriting the pod's environment variables (HAPPY_SERVER_URL, HAPPY_WEBAPP_URL, ANTHROPIC_API_KEY, etc.).

Test plan

  • Deploy updated image
  • Restart pod — confirm Happy daemon starts automatically
  • Connect from mobile app — should work without manually launching happy from terminal
  • Confirm webapp also responds

🤖 Generated with Claude Code

## Summary When `init-repo.sh` starts the Happy daemon it runs as **root**, so `HOME=/root`. Happy Coder and Claude Code look for credentials and config in `~/.happy` and `~/.claude`, which resolve to `/root/...` — not `/home/user/...` where the actual user credentials live. This is why: - ✅ `happy` launched from a VSCode terminal works (runs as `user`, correct home dir) - ❌ The background daemon doesn't work (runs as root, wrong home dir, missing credentials) The fix uses `sudo -u <user> -E` so the daemon runs as the correct user while still inheriting the pod's environment variables (`HAPPY_SERVER_URL`, `HAPPY_WEBAPP_URL`, `ANTHROPIC_API_KEY`, etc.). ## Test plan - [ ] Deploy updated image - [ ] Restart pod — confirm Happy daemon starts automatically - [ ] Connect from mobile app — should work without manually launching `happy` from terminal - [ ] Confirm webapp also responds 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.