{"record":{"id":"0e95315b33e1701a","repo":"composer/composer","slug":"could-not-retrieve-rar-archive-entries","errorCode":null,"errorMessage":"Could not retrieve RAR archive entries","messagePattern":"Could not retrieve RAR archive entries","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Composer/Downloader/RarDownloader.php","lineNumber":68,"sourceCode":"                . $iniMessage . \"\\n\" . $processError;\n\n            if (!Platform::isWindows()) {\n                $error = \"Could not decompress the archive, enable the PHP rar extension.\\n\" . $iniMessage;\n            }\n\n            throw new \\RuntimeException($error);\n        }\n\n        $rarArchive = RarArchive::open($file);\n\n        if (false === $rarArchive) {\n            throw new \\UnexpectedValueException('Could not open RAR archive: ' . $file);\n        }\n\n        $entries = $rarArchive->getEntries();\n\n        if (false === $entries) {\n            throw new \\RuntimeException('Could not retrieve RAR archive entries');\n        }\n\n        foreach ($entries as $entry) {\n            if (false === $entry->extract($path)) {\n                throw new \\RuntimeException('Could not extract entry');\n            }\n        }\n\n        $rarArchive->close();\n\n        return \\React\\Promise\\resolve(null);\n    }\n}\n","sourceCodeStart":50,"sourceCodeEnd":82,"githubUrl":"https://github.com/composer/composer/blob/c435d285c9120efdca35696769c72ea9fdcc0466/src/Composer/Downloader/RarDownloader.php#L50-L82","documentation":"Thrown by RarDownloader::extract() when RarArchive::getEntries() returns false after a successful open(). The archive opened but its entry list could not be enumerated, so there is nothing to iterate and extract.","triggerScenarios":"RarArchive::open() succeeded (returned an object) but getEntries() returns false — a partially corrupt header, an encrypted archive header, or an extension-level read failure.","commonSituations":"The RAR has an encrypted file list (header encryption) the extension cannot read without a password; corrupt central directory; extension bug on certain RAR variants.","solutions":["Test the archive with `unrar l <file>` to confirm the entry list is readable.","If the header is encrypted, supply the password or avoid such dist packages.","Re-download the archive in case of corruption.","Upgrade the rar extension / unrar binary to a newer version."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (class_exists(\\RarArchive::class)) {\n    $r = \\RarArchive::open($file);\n    if ($r !== false) {\n        if ($r->getEntries() === false) {\n            throw new \\RuntimeException('RAR entry list unreadable (encrypted header or corrupt).');\n        }\n        $r->close();\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    $downloader->install($package, $path);\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'Could not retrieve RAR archive entries')) {\n        // re-download; if header-encrypted, avoid this dist package\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Avoid header-encrypted RAR dists for automated installs.","Upgrade the rar extension to handle newer RAR variants.","Verify archives with `unrar t <file>` in CI."],"tags":["rar","archive","php-extension","corrupt-file"],"backgroundTag":null,"analyzedSha":"c435d285c9120efdca35696769c72ea9fdcc0466","analyzedAt":"2026-08-07T18:58:23.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}