From 32e87254d2b8ea48a9d8bb0679a01bafc8818aa5 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Fri, 20 Feb 2026 09:59:59 -0500 Subject: [PATCH] fix: run Happy daemon as app user, not root When init-repo.sh starts the happy daemon as root, HOME=/root so Happy and Claude Code can't find credentials stored in /home/user. The mobile app works when the user manually runs happy from a VSCode terminal (as the user user) because the right home dir is in scope. Use sudo -u with -E (preserve environment) so the daemon runs as the correct user while still inheriting the pod's env vars (HAPPY_SERVER_URL, HAPPY_WEBAPP_URL, ANTHROPIC_API_KEY, etc.). Co-Authored-By: Claude Sonnet 4.6 --- scripts/init-repo.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/init-repo.sh b/scripts/init-repo.sh index 6a707a0..45e257b 100644 --- a/scripts/init-repo.sh +++ b/scripts/init-repo.sh @@ -59,11 +59,13 @@ chown -R "$RUN_UID:$RUN_GID" "$WORKSPACE_DIR" mkdir -p "$HOME" chown "$RUN_UID:$RUN_GID" "$HOME" -# Start Happy Coder daemon +# Start Happy Coder daemon as the app user so it can access user credentials +# (running as root means HOME=/root, Claude Code and Happy config would be missing) echo "Starting Happy Coder..." -cd "$WORKSPACE_DIR" -happy daemon start || echo "Happy Coder daemon failed to start, continuing anyway..." +RUN_USER=$(id -nu "$RUN_UID" 2>/dev/null || echo "user") +sudo -u "$RUN_USER" -E sh -c "cd '$WORKSPACE_DIR' && happy daemon start" \ + || echo "Happy Coder daemon failed to start, continuing anyway..." echo "Happy Coder daemon started"