{"record":{"id":"117ecf6bf53ea4e0","repo":"rectorphp/rector","slug":"the-installed-package-json-not-found-make-sure-yo","errorCode":null,"errorMessage":"The installed package json not found. Make sure you run `composer update` and the \"vendor/composer/installed.json\" file exists","messagePattern":"The installed package json not found\\. Make sure you run `composer update` and the \"vendor/composer/installed\\.json\" file exists","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"src/Composer/InstalledPackageResolver.php","lineNumber":75,"sourceCode":"        // the previous file is no longer the source, drop what was read from it\n        $this->resolvedInstalledPackages = null;\n        $this->projectComposerJson = null;\n    }\n    /**\n     * @return array<string, InstalledPackage>\n     */\n    public function resolve(): array\n    {\n        // already cached, even only empty array\n        if ($this->resolvedInstalledPackages !== null) {\n            return $this->resolvedInstalledPackages;\n        }\n        if ($this->composerJsonFilePath !== null) {\n            return $this->resolvedInstalledPackages = $this->createPackagesFromConstraints();\n        }\n        $installedPackagesFilePath = $this->resolveVendorDir() . '/composer/installed.json';\n        if (!file_exists($installedPackagesFilePath)) {\n            throw new ShouldNotHappenException('The installed package json not found. Make sure you run `composer update` and the \"vendor/composer/installed.json\" file exists');\n        }\n        $installedPackageFileContents = FileSystem::read($installedPackagesFilePath);\n        $installedPackagesFilePath = Json::decode($installedPackageFileContents, \\true);\n        $installedPackages = $this->createInstalledPackages($installedPackagesFilePath['packages']);\n        $this->resolvedInstalledPackages = $installedPackages;\n        return $installedPackages;\n    }\n    public function resolvePackageVersion(string $packageName): ?string\n    {\n        $package = $this->resolve()[$packageName] ?? null;\n        if (!$package instanceof InstalledPackage) {\n            return null;\n        }\n        return $package->getVersion();\n    }\n    /**\n     * @param mixed[] $packages\n     * @return array<string, InstalledPackage>","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/src/Composer/InstalledPackageResolver.php#L57-L93","documentation":"InstalledPackageResolver::resolve() reads <project>/vendor/composer/installed.json (honoring a custom config.vendor-dir) to learn installed package versions; those versions drive version-bonded sets (e.g. rules targeting the installed symfony/http-foundation version) and ComposerBasedCommand. If the file does not exist it throws ShouldNotHappenException, meaning the project's dependencies were never installed in the directory Rector is running against.","triggerScenarios":"Running rector in a project where composer install/update has not been run (no vendor/), where vendor/ was pruned, where config.vendor-dir points elsewhere than where dependencies were installed, or where the phar is executed from a directory that is not the project root (wrong cwd).","commonSituations":"CI step order running rector before composer install; deployments that ship code without vendor; running the rector phar from a parent/monorepo directory while composer.json lives in a sub-package.","solutions":["Run composer install (or composer update) in the project root so vendor/composer/installed.json exists","Make sure you invoke rector from the directory that contains composer.json and vendor/ (check config.vendor-dir if customized)","In CI, add the composer-install step before the rector step","In monorepos, run rector per-package where the vendor lives, or point it at the package that owns the dependencies"],"exampleFix":"# before: CI runs rector on a fresh checkout\n- run: vendor/bin/rector process src  # vendor/ not installed yet\n\n# after: install dependencies first\n- run: composer install --prefer-dist\n- run: vendor/bin/rector process src","handlingStrategy":"validation","validationCode":"// preflight before invoking rector\n$vendorDir = 'vendor'; // adjust if composer config.vendor-dir is custom\nif (! is_file($vendorDir . '/composer/installed.json')) {\n    fwrite(STDERR, \"Dependencies not installed; run `composer install` first\\n\");\n    exit(1);\n}","typeGuard":null,"tryCatchPattern":"catch \\Rector\\Exception\\ShouldNotHappenException in wrappers around rector; if the message mentions installed.json, run composer install and retry once.","preventionTips":["Order CI steps: composer install always before rector","Run rector from the directory that owns composer.json and vendor/","Do not prune vendor/composer/* when slimming deployments if rector runs afterwards"],"tags":["php","rector","composer","installed-json","vendor","ci"],"backgroundTag":"missing-vendor-dependencies","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}