From d0736e47e3f8109d7f29446273ebabfbfbf12610 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Fri, 20 Feb 2026 10:04:15 -0600 Subject: [PATCH] fix: prevent composer install script from failing when prestissimo check runs as root The install-composer.sh script checked for /var/www/.composer/composer.json but ran 'composer global remove' as root, where COMPOSER_HOME resolves to /root/.config/composer. When that directory has no composer.json, the command fails and set -e kills the entire build step. Fix: use COMPOSER_HOME to find the correct global composer.json, and add || true to prevent failures from breaking the build. --- scripts/install-composer.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/install-composer.sh b/scripts/install-composer.sh index 3db228b4..d287c598 100755 --- a/scripts/install-composer.sh +++ b/scripts/install-composer.sh @@ -31,10 +31,12 @@ fi # Remove the setup script php -r "unlink('/tmp/composer-setup.php');" -# Check if anything is installed globally -if [ -f /var/www/.composer/composer.json ]; then - # If this is version 2 then let's make sure hirak/prestissimo is removed - if composer --version 2>/dev/null | grep -E "Composer (version )?2." > /dev/null; then - composer global remove hirak/prestissimo +# If upgrading from Composer 1 to 2, remove the prestissimo plugin +# which is incompatible with Composer 2 (parallel downloads are built-in now). +# Use COMPOSER_HOME to find the right global composer.json for the current user. +COMPOSER_HOME="${COMPOSER_HOME:-$(composer global config home --quiet 2>/dev/null || echo '')}" +if [ -n "$COMPOSER_HOME" ] && [ -f "$COMPOSER_HOME/composer.json" ]; then + if composer --version 2>/dev/null | grep -qE "Composer (version )?2\."; then + composer global remove hirak/prestissimo 2>/dev/null || true fi fi