Search code examples
cakephpcomposer-phpvagrant

CakePHP 4.x installation via Composer fails on plugin-installer


Platform and Target: Debian 10 with php 7.3.19-1~deb10u1

I have Vagrant installed and tried to create a new project with the latest cake version. After my vagrant up command, and login in via putty, I ran the command as provided on the cake website.

composer create-project --prefer-dist cakephp/app:~4.0 my_app_name

What happened

It then starts to run, installs the basic cake app, and tries to install the first plugin. It then crashes and does nothing anymore. It throws the following error:

Creating a "cakephp/app:~4.0" project at "./my_app_name"
Installing cakephp/app (4.2.1)
  - Installing cakephp/app (4.2.1): Extracting archive
Created project in /var/www/my_app_name
Loading composer repositories with package information
Updating dependencies
Lock file operations: 91 installs, 0 updates, 0 removals
  - Locking cakephp/bake (2.3.0)
  - (...)
  - Locking webmozart/assert (1.9.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 91 installs, 0 updates, 0 removals
  - Installing cakephp/plugin-installer (1.3.1): Extracting archive
Plugin initialization failed (include(/var/www/my_app_name/vendor/cakephp/plugin-installer/src/Plugin.php): failed to open stream: No such file or directory), uninstalling plugin
  - Removing cakephp/plugin-installer (1.3.1)
    Install of cakephp/plugin-installer failed


  [RuntimeException]
  Could not delete /var/www/my_app_name/vendor/cakephp/plugin-installer/src:


create-project [-s|--stability STABILITY] [--prefer-source] [...more options...]

I tried running with the --verbose parameter, but I'm not really getting wiser (you can find this at the bottom of the post). When I installed cake 4.2 via a direct download on github and ran composer update, it works just fine. When I installed composer.phar directly in the directory, it gives the exact same error again.

Any ideas on what could be the issue here?

My Vagrant setup

config.vm.box = 'bento/debian-10'

#!/usr/bin/env bash
echo "==> [ Entering bootstrap ]"

# VARS
DATABASE_NAME="webshop"

echo "==> Updating apt-get-get..."
apt-get update

echo "==> Installing/updating build-essential..."
apt-get install -y build-essential

# DOS2UNIX
if [ ! -f /usr/bin/dos2unix ]; then
    echo "==> Installing dos2unix..."
    apt-get install -y dos2unix
fi

# GIT
if [ ! -f /usr/bin/git ]; then
    echo "==> Installing GIT..."
    apt-get install -y git
fi

# APACHE
if [ ! -d /etc/apache2 ]; then
    echo "==> Installing Apache2..."
    apt-get install -y apache2
    a2enmod rewrite

    # Configure Apache
    echo "<VirtualHost *:80>
        DocumentRoot /var/www/webroot
        AllowEncodedSlashes On
        <Directory /var/www/webroot>
            Options +Indexes +FollowSymLinks
            DirectoryIndex index.php index.html
            Order allow,deny
            Allow from all
            AllowOverride All
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/vagrant_error.log
        CustomLog ${APACHE_LOG_DIR}/vagrant_access.log combined
    </VirtualHost>" > /etc/apache2/sites-available/000-default.conf
fi

# MYSQL
if [ ! -f /usr/bin/mariadb ]; then
    echo "==> Installing MySQL..."
    apt-get install -y mariadb-client mariadb-server

fi

echo "==> Creating databases..."
echo "CREATE DATABASE IF NOT EXISTS ${DATABASE_NAME} DEFAULT CHARACTER SET utf8" | mysql -uroot -proot
echo "CREATE DATABASE IF NOT EXISTS debug_kit DEFAULT CHARACTER SET utf8" | mysql -uroot -proot
echo "CREATE DATABASE IF NOT EXISTS test DEFAULT CHARACTER SET utf8" | mysql -uroot -proot
echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;" | mysql -uroot -proot
echo "flush privileges" | mysql -uroot -proot

# CURL
if [ ! -f /usr/bin/curl ]; then
    echo "==> Installing CURL..."
    apt-get install -y curl
fi

# PHP
if [ ! -f /usr/bin/php ]; then
    echo "==> Installing PHP..."
    # required by CakePHP
    apt-get install -y php7.3 php7.3-mbstring php7.3-intl php7.3-mysql
    # these are not...
    apt-get install -y php7.3-cli php7.3-curl php7.3-json php7.3-xdebug php7.3-zip
    # needed for phpunit
    apt-get install -y php7.3-xml php-zip
fi

if [ ! -f /usr/bin/zip ]; then
    apt-get install zip unzip
fi

# COMPOSER
if [ -e /usr/local/bin/composer ]; then
    /usr/local/bin/composer self-update
else
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
fi

# Reset home directory of vagrant user
if ! grep -q "cd /var/www" /home/vagrant/.profile; then
    echo "cd /var/www" >> /home/vagrant/.profile
fi

# RESTART
service apache2 restart
service mariadb restart

composer --verbose

Exception trace:
 () at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:218
 Composer\Util\Filesystem->unlink() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:171
 Composer\Util\Filesystem->removeDirectoryPhp() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:138
 Composer\Util\Filesystem->removeDirectory() at phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:378
 Composer\Downloader\FileDownloader->remove() at phar:///usr/local/bin/composer/src/Composer/Downloader/DownloadManager.php:349
 Composer\Downloader\DownloadManager->remove() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:299
 Composer\Installer\LibraryInstaller->removeCode() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:189
 Composer\Installer\LibraryInstaller->uninstall() at phar:///usr/local/bin/composer/src/Composer/Installer/PluginInstaller.php:121
 Composer\Installer\PluginInstaller->rollbackInstall() at phar:///usr/local/bin/composer/src/Composer/Installer/PluginInstaller.php:79
 Composer\Installer\PluginInstaller->Composer\Installer\{closure}() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:74
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95
 React\Promise\Deferred->resolve() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:76
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95
 React\Promise\Deferred->resolve() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:76
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95
 React\Promise\Deferred->resolve() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:76
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95
 React\Promise\Deferred->resolve() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20
 React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:76
 React\Promise\Deferred->React\Promise\{closure}() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:166
 React\Promise\Deferred->processQueue() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Deferred.php:95
 React\Promise\Deferred->resolve() at phar:///usr/local/bin/composer/vendor/react/promise/src/React/Promise/Promise.php:42
 React\Promise\Promise->React\Promise\{closure}() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php:284
 Composer\Util\ProcessExecutor->countActiveJobs() at phar:///usr/local/bin/composer/src/Composer/Util/Loop.php:95
 Composer\Util\Loop->wait() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:454
 Composer\Installer\InstallationManager->waitOnPromises() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:440
 Composer\Installer\InstallationManager->executeBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:367
 Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:266
 Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/composer/src/Composer/Installer.php:696
 Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:247
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/InstallCommand.php:131
 Composer\Command\InstallCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:310
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:122
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:63
 require() at /usr/local/bin/composer:24


Solution

  • Based of https://stackoverflow.com/a/63139337/1110760 & https://stackoverflow.com/a/65627308/1110760

    composer update --prefer-source


    The argument --no-plugins worked as well, sort of. It skipped some packages but my localhost seemed to work just fine. This is faster, but it's missing some.