RobLoach/component-installer

Fails on removing: PHP Fatal error: Class 'ComponentInstaller\Process\CopyProcess' not found

Closed this issue · 8 comments

$ ls -1
composer.json
$ cat composer.json 
{
    "require": {
        "components/jquery": "1.9.*",
        "components/normalize.css": "2.*"
    }
}
$ composer install
# ... everything ok ...
$ cat composer.json 
{
}
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing components/normalize.css (2.1.1)
  - Removing components/jquery (1.9.1)
  - Removing robloach/component-installer (0.0.12)
  - Removing kriswallsmith/assetic (v1.1.2)
  - Removing symfony/process (v2.3.5)
Generating autoload files
Compiling component files
PHP Fatal error:  Class 'ComponentInstaller\Process\CopyProcess' not found in /.../vendor/robloach/component-installer/src/ComponentInstaller/Installer.php on line 160
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/composer:0
PHP   2. require() /usr/local/bin/composer:15
PHP   3. Composer\Console\Application->run() phar:///usr/local/bin/composer/bin/composer:43
PHP   4. Symfony\Component\Console\Application->run() phar:///usr/local/bin/composer/src/Composer/Console/Application.php:83
PHP   5. Composer\Console\Application->doRun() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:121
PHP   6. Symfony\Component\Console\Application->doRun() phar:///usr/local/bin/composer/src/Composer/Console/Application.php:117
PHP   7. Symfony\Component\Console\Application->doRunCommand() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:191
PHP   8. Symfony\Component\Console\Command\Command->run() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:897
PHP   9. Composer\Command\UpdateCommand->execute() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
PHP  10. Composer\Installer->run() phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:116
PHP  11. Composer\Autoload\AutoloadGenerator->dump() phar:///usr/local/bin/composer/src/Composer/Installer.php:283
PHP  12. Composer\EventDispatcher\EventDispatcher->dispatchScript() phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:194
PHP  13. Composer\EventDispatcher\EventDispatcher->doDispatch() phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:84
PHP  14. Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:138
PHP  15. ComponentInstaller\Installer::postAutoloadDump() phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:165

Fatal error: Class 'ComponentInstaller\Process\CopyProcess' not found in /.../vendor/robloach/component-installer/src/ComponentInstaller/Installer.php on line 160

Call Stack:
    0.0001     640320   1. {main}() /usr/local/bin/composer:0
    0.0053     842136   2. require('phar:///usr/local/bin/composer/bin/composer') /usr/local/bin/composer:15
    0.0375    5582176   3. Composer\Console\Application->run() phar:///usr/local/bin/composer/bin/composer:43
    0.0411    6181232   4. Symfony\Component\Console\Application->run() phar:///usr/local/bin/composer/src/Composer/Console/Application.php:83
    0.0425    6433296   5. Composer\Console\Application->doRun() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:121
    0.0435    6592480   6. Symfony\Component\Console\Application->doRun() phar:///usr/local/bin/composer/src/Composer/Console/Application.php:117
    0.0444    6592480   7. Symfony\Component\Console\Application->doRunCommand() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:191
    0.0444    6592480   8. Symfony\Component\Console\Command\Command->run() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:897
    0.0450    6590776   9. Composer\Command\UpdateCommand->execute() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
    0.1494   13029480  10. Composer\Installer->run() phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:116
   10.3450   84349920  11. Composer\Autoload\AutoloadGenerator->dump() phar:///usr/local/bin/composer/src/Composer/Installer.php:283
   10.3464   84359800  12. Composer\EventDispatcher\EventDispatcher->dispatchScript() phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:194
   10.3464   84361024  13. Composer\EventDispatcher\EventDispatcher->doDispatch() phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:84
   10.3466   84363968  14. Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:138
   10.3466   84363968  15. ComponentInstaller\Installer::postAutoloadDump() phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:165

$ ls -1 components/
require-built.js
require.config.js
require.css
require.js

I have just encountered this as well. I tthink it fails because it tries to use a class from the component installer after robloach/component-installer is already removed. By requiring the component installer in the root composer.json this can only partially be fixed because it will still occur when removing the component installer itself.

If there is no simple solution to detecting if the component installer shall remove itself then I suggest autoloading all classes at the beginning so the autoloader will never be called to load a class from a file that is no longer there.

I have the same problem

Wouldn't it be enough to use class_exists before trying to instantiate the class?

I have the same problem. But it appeared once, the next time for update it was no longer

Still occurs, we use CloudControl to deploy our code to their instances. Their deployment process supports using Composer, but removing the component installer results in failed deployments..

Related: #68

Removal succeeds with this PR:

composer update --verbose -vv
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing robloach/component-installer (dev-master)
  - Removing kriswallsmith/assetic (v1.2.1)
  - Removing symfony/process (v2.6.6)
Writing lock file
Generating autoload files
Compiling component files
Process class 'ComponentInstaller\Process\CopyProcess' not found, skip this process
Process class 'ComponentInstaller\Process\RequireJsProcess' not found, skip this process
Process class 'ComponentInstaller\Process\RequireCssProcess' not found, skip this process
Process class 'ComponentInstaller\Process\BuildJsProcess' not found, skip this process

Thanks a lot, guys!