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

Uncaught Error: Class "Composer\InstalledVersions" not found [phar] #7329

Closed
thbley opened this issue Jan 7, 2022 · 11 comments · Fixed by #7337
Closed

Uncaught Error: Class "Composer\InstalledVersions" not found [phar] #7329

thbley opened this issue Jan 7, 2022 · 11 comments · Fixed by #7337

Comments

@thbley
Copy link
Contributor

thbley commented Jan 7, 2022

psalm.phar -v
Uncaught Error: Class "Composer\InstalledVersions" not found in phar:///home/psalm.phar/src/Psalm/Internal/CliUtils.php:116
Stack trace:
#0 phar:///home/psalm.phar/src/Psalm/Internal/Cli/Psalm.php(188): Psalm\Internal\CliUtils::requireAutoloaders()
#1 phar:///home/psalm.phar/src/Psalm/Internal/IncludeCollector.php(31): Psalm\Internal\Cli\Psalm::Psalm\Internal\Cli\{closure}()
#2 phar:///home/psalm.phar/src/Psalm/Internal/Cli/Psalm.php(189): Psalm\Internal\IncludeCollector->runAndCollect()
#3 phar:///home/psalm.phar/psalm(7): Psalm\Internal\Cli\Psalm::run()
#4 /home/psalm.phar(14): require('...')
#5 {main}
(Psalm (unknown version) crashed due to an uncaught Throwable)

Version 4.18, PHP 8.1.1 or 8.0.x

Source code inside phar:

Screenshot_20220107_110341

@villfa
Copy link
Contributor

villfa commented Jan 7, 2022

A new version of Box has been released 4 days ago: https://github.com/box-project/box/releases/tag/3.14.1
It's probably related.

A way to avoid a surprise like that could be to commit the composer.lock file in vendor-bin/box.

@orklah
Copy link
Collaborator

orklah commented Jan 7, 2022

Not sure it's related. We merged this #7239 in last version. There must be something wrong here, possibly related to our scoper.inc.php file

@orklah
Copy link
Collaborator

orklah commented Jan 7, 2022

Hey All, can some of you try this phar and tell me if it fixes your issue? https://30363-74386167-gh.circle-artifacts.com/0/build/psalm.phar

@orklah orklah reopened this Jan 7, 2022
@orklah
Copy link
Collaborator

orklah commented Jan 7, 2022

Note: One of phpdoc's repo is failing due to another error with the phar:
https://github.com/phpDocumentor/TypeResolver/runs/4743694679?check_suite_focus=true#step:7:9

@villfa
Copy link
Contributor

villfa commented Jan 7, 2022

Hey All, can some of you try this phar and tell me if it fixes your issue? https://30363-74386167-gh.circle-artifacts.com/0/build/psalm.phar

There is still an error:

./psalm.phar -v
Uncaught OutOfBoundsException: Package "nikic/php-parser" is not installed in /vendor/composer/InstalledVersions.php:180
Stack trace:
#0 phar:///psalm.phar/src/Psalm/Internal/CliUtils.php(123): Composer\InstalledVersions::getVersion('nikic/php-parse...')
#1 phar:///psalm.phar/src/Psalm/Internal/Cli/Psalm.php(188): Psalm\Internal\CliUtils::requireAutoloaders('/', false, 'vendor')
#2 phar:///psalm.phar/src/Psalm/Internal/IncludeCollector.php(31): Psalm\Internal\Cli\Psalm::Psalm\Internal\Cli\{closure}()
#3 phar:///psalm.phar/src/Psalm/Internal/Cli/Psalm.php(189): Psalm\Internal\IncludeCollector->runAndCollect(Object(Closure))
#4 phar:///psalm.phar/psalm(7): Psalm\Internal\Cli\Psalm::run(Array)
#5 /psalm.phar(14): require('phar://...')
#6 {main}
(Psalm UNKNOWN crashed due to an uncaught Throwable)

@orklah
Copy link
Collaborator

orklah commented Jan 7, 2022

I'm not sure if this is expected that vendors are not considered installed in phars.

The version is used to generate a hash for cache purposes. I'm afraid setting this to null would lead to cache corruption. But at the same time, I see that we caught the same exception on the Psalm version check. @DeyV was there a reason to try/catch the psalm version and not the php-parser one?

@weirdan
Copy link
Collaborator

weirdan commented Jan 8, 2022

I believe the linked issue in php-scoper causes this. The best course of action, I think, is to revert #7239 for now.

@orklah
Copy link
Collaborator

orklah commented Jan 8, 2022

I'm not sure this is the same issue. The "class not found" issue seems fixed. Now we just have an issue with the composer API that doesn't return versions when inside the phar

@weirdan
Copy link
Collaborator

weirdan commented Jan 8, 2022

I am positive it's the root cause. The fix for class not found you added is likely to cause more issues down the line, so I'll be reverting that as well.

@orklah
Copy link
Collaborator

orklah commented Jan 8, 2022

okay then, but it seems to me we already have this hack elsewhere. I literally just copy/pasted another piece of code

EDIT: specifically this one:

// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName

@weirdan
Copy link
Collaborator

weirdan commented Jan 8, 2022

Fixed in #7346 and released 4.18.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants