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 <noreply@anthropic.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user