Repository: composer/composer

Issue #3000: Add plugin::deactivate() method
Created: 2014-05-19T23:26:57Z
I've encountered really strange behavior of composer. When custom installer is removed from dependencies, I get an error saying that its class can't be found. I may be wrong but, as far as I see in composer source, first it is registered as an installer in Composer\Plugin\PluginManager::registerPackage() and then it gets phisically removed.
Steps to reproduce:

Initialize empty composer.json
Add custom installer, In my case bug occured with robloach/component-installer 0.0.12 so the line would be:
"robloach/component-installer": "0.0.12"
Run composer install
Remove requirement
Run composer update
PHP Fatal error:  Class 'ComponentInstaller\Process\CopyProcess' not found in /home/mikz/temp/composerTest/vendor/robloach/component-installer/src/ComponentInstaller/Installer.php on line 160

Duplicate issue #5236: Composer update runs post-update scripts of packages being removed
Created: 2016-04-23T13:29:48Z
Given a set of installed packages that contain a post-update-cmd:
{
    "require": {
        "ocramius/package-versions": "^1.0"
    }
}
When I change the composer.json to following (empty, on purpose):
{
}
When I run composer update -vvv, then composer still tries to run post-update-cmd of ocramius/package-versions:
∙ composer update -vvv                                                                                                                                                            15:24  ocramius@Marcos-MacBook-Pro
Running b6680b6f2ab831f3918ca3be42d5cb2594f830ad (2016-04-21 21:16:05) with PHP 7.0.5 on Darwin / 15.4.0
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Reading ./composer.json
Loading config file /Users/ocramius/.composer/config.json
Loading config file /Users/ocramius/.composer/auth.json
Loading config file ./composer.json
Checked CA file /private/var/folders/c_/3k15s94s6bj35qywyr7c74mm0000gn/T/composer-cacert-bcf331364fef73d53e4368ba519a6c3fcb21ea7836c3d8efad4ec32731e8152a.pem: valid
Executing command (/Users/ocramius/Desktop/foo): git branch --no-color --no-abbrev -v
Executing command (/Users/ocramius/Desktop/foo): git describe --exact-match --tags
Reading /Users/ocramius/.composer/composer.json
Loading config file /Users/ocramius/.composer/config.json
Loading config file /Users/ocramius/.composer/auth.json
Loading config file /Users/ocramius/.composer/composer.json
Loading config file /Users/ocramius/.composer/auth.json
Reading /Users/ocramius/Desktop/foo/vendor/composer/installed.json
Reading /Users/ocramius/.composer/vendor/composer/installed.json
Loading plugin PackageVersions\Installer
Loading composer repositories with package information
Downloading https://packagist.org/packages.json
Writing /Users/ocramius/.composer/cache/repo/https---packagist.org/packages.json into cache
Updating dependencies (including require-dev)
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-2013.json from cache
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-2014.json from cache
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-2015.json from cache
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-2015-07.json from cache
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-2015-10.json from cache
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-2016-01.json from cache
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-2016-04.json from cache
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-archived.json from cache
Downloading http://packagist.org/p/provider-latest%24bf51d4ca472c3c34527bc5048269ff2b6262569adb459fd4325d1f2ff7698b9c.json
Writing /Users/ocramius/.composer/cache/repo/https---packagist.org/p-provider-latest.json into cache
Reading /Users/ocramius/.composer/cache/repo/https---packagist.org/provider-ocramius$package-versions.json from cache
Resolving dependencies through SAT
Dependency resolution completed in 0.001 seconds
Analyzed 73 packages to resolve dependencies
Analyzed 70 rules to resolve dependencies
  - Removing ocramius/package-versions (1.0.3)
Reading /Users/ocramius/Desktop/foo/vendor/composer/installed.json
Generating autoload files
ocramius/package-versions:  Generating version class...


  [LogicException]
  No lockfile found. Unable to read locked packages


Exception trace:
 () at phar:///usr/local/bin/composer/src/Composer/Package/Locker.php:260
 Composer\Package\Locker->getLockData() at /Users/ocramius/Desktop/foo/vendor/ocramius/package-versions/src/PackageVersions/Installer.php:166
 PackageVersions\Installer::getVersions() at n/a:n/a
 iterator_to_array() at /Users/ocramius/Desktop/foo/vendor/ocramius/package-versions/src/PackageVersions/Installer.php:102
 PackageVersions\Installer::generateVersionsClass() at /Users/ocramius/Desktop/foo/vendor/ocramius/package-versions/src/PackageVersions/Installer.php:90
 PackageVersions\Installer::dumpVersionsClass() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:170
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:95
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///usr/local/bin/composer/src/Composer/Installer.php:296
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:173
 Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:844
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:197
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:123
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:99
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
 require() at /usr/local/bin/composer:25

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

This is means that composer tries to run code from a package that isn't installed anymore, and things crash and burn. In this case, it doesn't like the composer.lock not being there, but PackageVersions\Installer may depend on other classes in the package that was just removed, and therefore things may crash and burn there too...
Is this intended behavior? If so, what hooks should the package use to listen to any update, yet "disable itself" if it is removed?

Closing comment (2016-04-24T12:54:40Z): Duplicate of #3000