By mlsandreas on
I tried to install drumal cms and i get the following error. Just for the info , drupal core installs with no problem. Any ideas?
An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /core/install.php?rewrite=ok&profile=drupal_cms_installer&langcode=en&name=1&template=1&id=1&op=do_nojs&op=do StatusText: OK ResponseText: Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/bin/php' '/var/www/drupal/vendor/composer/./composer/bin/composer' '--no-interaction' 'config' 'extra.drupal-scaffold.allowed-packages' '--merge' '--json' '["drupal/provus_edu"]'" failed. Exit Code: 1(General error) Working directory: /var/www/drupal/vendor/composer/../../ Output: ================ Error Output: ================ In Factory.php line 727: The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [-j|--json] [-m|--merge] [--append] [--source] [--] [<setting-key> [<setting-value>...]] in Symfony\Component\Process\Process->mustRun() (line 291 of /var/www/drupal/vendor/symfony/process/Process.php).
Comments
Composer has no HOME under the web server user
The cause is in the error text itself: "The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly". Nothing is wrong with your Drupal or your Ubuntu version.
This is also why core installs fine and Drupal CMS doesn't. The core installer never shells out to Composer. The Drupal CMS installer does, because it adds recipe packages as you pick them, which is the composer config extra.drupal-scaffold.allowed-packages call in your trace. That command runs as the web server user, and www-data normally has no usable HOME, so Composer refuses to start.
To fix it, give the web server user a Composer home it can write to:
sudo mkdir -p /var/www/.composer
sudo chown -R www-data:www-data /var/www/.composer
Then set the variable for the PHP process rather than for your shell, which is the part people usually miss. If you're on PHP-FPM, edit the pool config (something like /etc/php/8.3/fpm/pool.d/www.conf, adjust for your PHP version) and add:
env[COMPOSER_HOME] = /var/www/.composer
Then restart: sudo systemctl restart php8.3-fpm
If you're running mod_php under Apache instead, put export COMPOSER_HOME=/var/www/.composer in /etc/apache2/envvars and restart Apache.
Setting it in your own shell won't help, because the failing command is being run by the web server, not by you. That's the usual reason people try COMPOSER_HOME and report it didn't work.
One thing worth checking after the install completes: whether the directory stays writable by www-data. A web server that can write its own Composer home and vendor directory is convenient during install and not something you want to leave in place on a production box.