-
Notifications
You must be signed in to change notification settings - Fork 174
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
It doesn't work with composer 2 #383
Comments
It should, are you encountering any particular issue? |
I am currently struggling with the problem as well. When run phpstan see error:
Sentry version:
|
@Yozhef that seems unrelated; it also seems that you're doing something strange with @cataragak90 the CI just run successfully with Composer 2.0.2: https://github.com/getsentry/sentry-symfony/runs/1315282756?check_suite_focus=true#step:4:11 so it doesn't seem an issue on my side. |
It seems related to Composer because I had to add a conflict with Composer >= 2 to fix this error. Why do you think there is something strange with |
@VincentLanglet you correctly thought the problem in PHPStan when in config |
@Jean85 I think it is possible to close Sentry supports Composer 2 - we have already started testing our project. |
Do you require phpunit in your project ?
In order to load the phpunit classes. So I still believe there is something wrong between Composer 2 / Sentry/symfony and the usage of pretty version. |
Which version of |
If I remove the
I use
When phpunit-bridge is installing dependencies, a class It seems like I'm using composer 1 for my project but phpunit is using composer 2. And then your library is believing I'm using composer 2. |
It seems to me that you're having issues with the PHPUnit Bridge then... Oh but you already opened symfony/symfony#38889 (and closed it too early IMHO). |
I'm having the same issue with the Sentry bundle, PHPStan and the PHPUnit bridge... I think it could be solved by requiring EDIT: Well, nope! I will wait for symfony/symfony#38889 and phpstan/phpstan#4022 to be fixed and configure the CI for using Composer 1 😅 |
Hey, Thanks in advance! |
I investigated this a bit further - the error appears when adding the following configuration:
It is also somehow related to the the
|
The problem here is that there is now a: There is a workaround by override the InstalledVersions again using the following in the bootstrapFiles:
- bin/.phpunit/phpunit-8.5-0/vendor/autoload.php
- vendor/composer/InstalledVersions.php # workaround for: https://github.com/getsentry/sentry-symfony/issues/383 |
@alexander-schranz Who do you think this issue should be addressed to ? Either their could be something to improve to |
Not sure where this could be fixed its a combination of 3 different libraries so maybe we can get some feedback from one of there core contributers:
|
In symfony/proxy-manager-bridge this was fixed by stopping using Version class and doing feature detection instead: symfony/symfony#39017 I guess a similar thing could be done in phpunit-bridge as well. |
@ondrejmirtes thx for the fast response 🚀 . Sentry uses the version to get the version of itself (example). To tell there api which version of there library did the request the endpoint. So the fix sentry could do here is adding a |
@alexander-schranz Also what would probably help with the problem would be to get the version lazily once it's needed so that it gets out of this stack trace:
|
@ondrejmirtes could not find a way for it, it seems always be triggered because used at constructing and configure container services. |
PHPStan could merge arrays from all the used Composer autoloaders, but I'd need a failing integration test similar to this one phpstan/phpstan#4047 first from someone that's experiencing this error. Thanks. |
@ondrejmirtes any reason for not doing it yet? Can we help somehow? |
@ondrejmirtes but it'll load an outdated ClassLoader which makes this whole fix in Composer not work if the ClassLoader does not have getRegisteredLoaders on it. So regardless it's not the best use case to test if this fix works. |
Until recently humbug/box or php-scoper combo weren't compatible with Composer v2. Also I thought that building PHAR with Composer v2 would actually make this problem worse. Because right now to bump into this problem (if I understand it correctly) you need to have two conflicting Composer v2 If you need PHPStan built with Composer v2 in order to verify this fix, I can look into it again and produce the updated PHAR for |
I guess the thing is @alexander-schranz has |
The order of loading is:
So I think this is true in the current version of PHPStan:
|
Ok then I don't understand what is going on, but I also don't have all the information.. |
I'll just try to build the PHAR with Composer v2 and see what happens. |
I tried building PHPStan PHAR with |
You can add a |
@Jean85 I bumped into this problem (box-project/box#528). I guess the PHAR is now completely broken for this purpose and won't be able to find any package version. |
Alright, so I was able to work around the problem. @alexander-schranz Can you please try the latest |
I don't know if it can help you but I tried on my CI
But I still get
Tried to only change But if I do all of this:
It works !!! |
I think these steps should work:
This shouldn't be necessary but it probably just triggered exporting the new autoloader: Adding "composer/composer": "2.0.x-dev" in my composer.json |
@ondrejmirtes @Seldaek the issue is gone with the |
Awesome, I'm happy to release PHPStan once Composer is released and |
2.0.9 is out |
Great job everyone! |
I just released PHPStan 0.12.70 that contains the fix :) https://github.com/phpstan/phpstan/releases/tag/0.12.70 |
@ondrejmirtes it does not work anymore for me. e238668648be5ff3225875c39346bd9a16f5438b was working |
For me it still works. I did: composer self-update --2 # did get the new 2.0.9
# removed the old autoloader files
rm -rf vendor
rm -rf bin/.phpunit
composer update phpstan/phpstan # to get phpstan 0.12.70 and in this case also the new autoloader
bin/phpunit install # generate the phpunit autoloader
vendor/bin/phpstan analyse # no errors did appear @VincentLanglet did you in your case reinstall the dependencies so both autoloaders are also reinstalled? |
I think I had some weird issue with my CI, it's fixed now :) |
And now the fun starts... phpstan/phpstan#4453 I hope it can be solved by the steps I've written there... |
Is it supposed to work with composer 2?
The text was updated successfully, but these errors were encountered: