-
Notifications
You must be signed in to change notification settings - Fork 9
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
OutOfBoundsException Package "vimeo/psalm" is not installed. Fallback to versions available in this package when Composer\InstalledVersions check fails. #27
Comments
Looking into this, it seems the package version does exist as expected in However it's call to the Could we not catch these exceptions, and fallback to available versions within this package returning those where available or allowing the exception to bubble where they're not? Something akin to.. final class Versions
{
...
/**
* @throws OutOfBoundsException If a version cannot be located.
*
* @psalm-param key-of<self::VERSIONS> $packageName
* @psalm-pure
*
* @psalm-suppress ImpureMethodCall we know that {@see InstalledVersions} interaction does not
* cause any side effects here.
*/
public static function getVersion(string $packageName): string
{
if (class_exists(InstalledVersions::class, false) && (method_exists(InstalledVersions::class, 'getAllRawData') ? InstalledVersions::getAllRawData() : InstalledVersions::getRawData())) {
try {
return InstalledVersions::getPrettyVersion($packageName)
. '@' . InstalledVersions::getReference($packageName);
}
catch (OutOfBoundsException $e) {
if (isset(self::VERSIONS[$packageName])) {
return self::VERSIONS[$packageName];
}
throw $e;
}
}
if (isset(self::VERSIONS[$packageName])) {
return self::VERSIONS[$packageName];
}
throw new OutOfBoundsException(
'Required package "' . $packageName . '" is not installed: check your ./vendor/composer/installed.json and/or ./composer.lock files'
);
}
} This seems to fix the issue, but approach could probably be rewritten/reworked. |
I cannot reproduce this with Composer 2. I'd definitely like to understand the exact problem before merging such a hacky-looking PR. I think probably what happens is that you run Composer 1, but have Composer 2 installed, so IMO the solution here is to upgrade to Composer 2. Or possibly to avoid requiring composer/composer, I'm not sure why you have it in your vendor dir but it's usually a bad idea. |
This is very much an issue with Composer 1, the issue does not occur when running Composer 2. I came across this issue when developing a plugin (see https://github.com/JParkinson1991/composer-linker-plugin/tree/feature/actions_fix) that was to be compatible with both Composer 1 and Composer 2. When developing the plugin it is useful to require (dev) The problem seems to be isolated to using Composer at version 1, but having |
Ok, sorry but I'd rather not add the catch there as I feel it makes the flow even harder to understand if something gets returned which is not what you expect. Plus this package should anyway long term not be used if you are using Composer 2. |
No problem at all, long term moving to composer 2 should always be the aim. That being said, can you elaborate on the following:
I'm confused as to what is being returned that the method caller wouldn't expect? Calling |
What scares me a little is this only happens when two versions of composer run concurrently in the same process to some extent, which means possibly some things are out of sync and you may get data from a vendor dir you aren't expecting or I don't know what exactly. It seems like failing hard is the safer and better choice here. |
Just wanted to chime in as I just ran into this as well --
Can confirm that I have both versions of composer installed in my docker container (as I use the same image for various apps, some which have migrated to composer 2 already and some that have not) Did some debugging
However, the package is listed in Perhaps we could expand this condition to check that the array isn't empty? Just a thought. |
…n vendor but project was installed with Composer 1, fixes #27
Ok I did fix this I believe in b8d9f63 - if one of you can please try it out using |
…n vendor but project was installed with Composer 1, fixes #27
@Seldaek just tested this all seems to be working as expected. As previously mentioned it seemed issues was isolated to a composer 1 binary install and a package/library composer/composer install of > 2. Using the below i am unable to reproduce the original errors. composer.json {
"name": "composer/package-versions-deprecated-dev-master-test",
"type": "library",
"require": {
"composer/package-versions-deprecated": "dev-master",
"composer/composer": "^2.0",
"vimeo/psalm": "^4.8"
}
} CLI Output (post library install):
|
OK thanks for the confirmation, released as 1.11.99.3 |
Hello,
Trying to install and use
vimeo/psalm
in a local project but keep gettingOutOfBoundsException
when trying to access it's binary.Composer Version: 1.10.22
PHP Version: 7.3.28 | 7.4.20
Having dug into this a little further it seems to be the cause of the issue is in 'composer/composer'. (So apologies if this is not the right place)
Steps To Reproduce
Working Example
Is it the case that psalm is not compatible with composer/compose 2? Anything that we can do here?
The text was updated successfully, but these errors were encountered: