Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError when a JSON file can not be read #10818

Merged
merged 1 commit into from
Jun 4, 2022

Conversation

villfa
Copy link
Contributor

@villfa villfa commented Jun 3, 2022

Hi,

I got the following error with Composer 2.3.5 but it affects also the 2.2 branch.

It happened after running composer install, but unfortunately I didn't manage to reproduce the problem afterwards.

Fatal error: Uncaught TypeError: Composer\Json\JsonFile::parseJson(): Argument #1 ($json) must be of type ?string, bool given, called in phar:///usr/local/bin/composer/src/Composer/Json/JsonFile.php on line 117 and defined in phar:///usr/local/bin/composer/src/Composer/Json/JsonFile.php:311
Stack trace:
#0 phar:///usr/local/bin/composer/src/Composer/Json/JsonFile.php(117): Composer\Json\JsonFile::parseJson(false, '/var/www/vendor...')
#1 phar:///usr/local/bin/composer/src/Composer/Repository/FilesystemRepository.php(82): Composer\Json\JsonFile->read()
#2 phar:///usr/local/bin/composer/src/Composer/Repository/ArrayRepository.php(311): Composer\Repository\FilesystemRepository->initialize()
#3 phar:///usr/local/bin/composer/src/Composer/Factory.php(590): Composer\Repository\ArrayRepository->getPackages()
#4 phar:///usr/local/bin/composer/src/Composer/Factory.php(435): Composer\Factory->purgePackages(Object(Composer\Repository\InstalledFilesystemRepository), Object(Composer\Installer\InstallationManager))
#5 phar:///usr/local/bin/composer/src/Composer/Factory.php(614): Composer\Factory->createComposer(Object(Composer\IO\ConsoleIO), Array, true, '/var/www', true, false)
#6 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(469): Composer\Factory::create(Object(Composer\IO\ConsoleIO), NULL, true, false)
#7 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(411): Composer\Console\Application->getComposer(false, true)
#8 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(352): Composer\Console\Application->hintCommonErrors(Object(ErrorException), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(171): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(130): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar:///usr/local/bin/composer/bin/composer(88): Composer\Console\Application->run()
#12 /usr/local/bin/composer(29): require('phar:///usr/loc...')
#13 {main}
  thrown in phar:///usr/local/bin/composer/src/Composer/Json/JsonFile.php on line 311

PHP version: 8.0.17

@Seldaek
Copy link
Member

Seldaek commented Jun 4, 2022

Weird that it would fail without throwing above, really wonder how that happened, but I guess this strictly doesn't hurt so thanks

@Seldaek Seldaek merged commit 1e9210f into composer:2.2 Jun 4, 2022
@Seldaek Seldaek added this to the 2.2 milestone Jun 4, 2022
@villfa villfa deleted the fix/jsonfile branch June 4, 2022 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants