{"record":{"id":"cf9fb147a1276af4","repo":"composer/composer","slug":"package-is-not-installed-initial-cf9fb1","errorCode":null,"errorMessage":"Package is not installed: {initial}","messagePattern":"Package is not installed: (.+?)","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Composer/Installer/NoopInstaller.php","lineNumber":85,"sourceCode":"    /**\n     * @inheritDoc\n     */\n    public function install(InstalledRepositoryInterface $repo, PackageInterface $package)\n    {\n        if (!$repo->hasPackage($package)) {\n            $repo->addPackage(clone $package);\n        }\n\n        return \\React\\Promise\\resolve(null);\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)\n    {\n        if (!$repo->hasPackage($initial)) {\n            throw new \\InvalidArgumentException('Package is not installed: '.$initial);\n        }\n\n        $repo->removePackage($initial);\n        if (!$repo->hasPackage($target)) {\n            $repo->addPackage(clone $target);\n        }\n\n        return \\React\\Promise\\resolve(null);\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)\n    {\n        if (!$repo->hasPackage($package)) {\n            throw new \\InvalidArgumentException('Package is not installed: '.$package);\n        }","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/composer/composer/blob/6ffc1177404d0c50119c22dde6564a380f4a82c9/src/Composer/Installer/NoopInstaller.php#L67-L103","documentation":"Thrown by NoopInstaller::update() when the installed repository lacks the $initial package. NoopInstaller is used for dry runs; it still validates that the source package is registered before swapping entries (NoopInstaller.php:84-86).","triggerScenarios":"Running a dry-run update where $repo->hasPackage($initial) is false — the simulated update targets a package the local repo doesn't track.","commonSituations":"Dry-running an update against a desynced installed.json; vendored state altered before the dry run; re-running a dry-run update after state changed.","solutions":["Run `composer install` first so the local repo matches the lock before dry-run updates.","Ensure the dry run is executed against a coherent repository state.","Skip update operations for packages already absent from the repo."],"exampleFix":"// before\n$installer->update($repo, $initial, $target); // NoopInstaller dry run, $initial missing\n\n// after\nshell_exec('composer install'); // reconcile, then retry the dry-run update","handlingStrategy":"validation","validationCode":"if (!$repo->hasPackage($initial)) {\n    if (!$repo->hasPackage($target)) {\n        $installer->install($repo, $target);\n    }\n    return;\n}\n$installer->update($repo, $initial, $target);","typeGuard":null,"tryCatchPattern":"try {\n    $installer->update($repo, $initial, $target);\n} catch (\\InvalidArgumentException $e) {\n    // dry-run against desynced repo: reconcile, then re-run the simulation\n}","preventionTips":["Run `composer install` to sync installed.json before dry-run updates.","Guard dry-run updates with hasPackage().","Re-run dry runs from a clean, consistent repository state."],"tags":["installer","repository","dry-run","state-corruption","update"],"analyzedSha":"6ffc1177404d0c50119c22dde6564a380f4a82c9","analyzedAt":"2026-08-07T00:01:08.491Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}