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

Exit code of prohibits (why-not) is always 0 #11796

Closed
InvisibleSmiley opened this issue Jan 15, 2024 · 3 comments
Closed

Exit code of prohibits (why-not) is always 0 #11796

InvisibleSmiley opened this issue Jan 15, 2024 · 3 comments
Labels
Milestone

Comments

@InvisibleSmiley
Copy link

composer.json:

{
  "require": {
    "php": "^8.1",
    "psr/log": "^3"
  }
}

When I run this command:

composer why-not php 100

I get the following output:

Package "php" could not be found with constraint "100", results below will most likely be incomplete.
__root__ - requires php (^8.1)
Not finding what you were looking for? Try calling `composer update "php:100" --dry-run` to get another view on the problem.

with exit code 0.

And I expected this to happen:
Exit code > 0

Compare that to the "OK" case:

When I run this command:

composer why-not php ^8.1

I get the following output:

There is no installed package depending on "php" in versions not matching ^8.1
Not finding what you were looking for? Try calling `composer update "php:^8.1" --dry-run` to get another view on the problem.

with exit code 0.

So right now the only way to determine that we have a problem in the one case but not the other is to parse the output.
That's very unfortunate (and unexpected, at least for me).

Please note that what I need is a way to distinguish the cases where there is an actual problem from those where there is none.

For example if you execute the below, you'll receive a warning/error hinting at possibly incomplete results but that should not count as an error as far as the exit code is concerned:

When I run this command:

composer why-not php ^8.2

I get the following output:

Package "php" could not be found with constraint "^8.2", results below will most likely be incomplete.
There is no installed package depending on "php" in versions not matching ^8.2
Not finding what you were looking for? Try calling `composer update "php:^8.2" --dry-run` to get another view on the problem.

with exit code 0.

@Seldaek
Copy link
Member

Seldaek commented Jan 18, 2024

Well those are not wrong per se.. They are nonsensical as you used php version 100 but that's just you and I knowing that is unlikely. If you used php 9 you will also not find anything, even tho that's a much less nonsensical prompt, and in both cases it is not something Composer can know is wrong IMO.

So I am not sure in what case you would expect a non-zero exit code.

@InvisibleSmiley
Copy link
Author

InvisibleSmiley commented Jan 18, 2024

Sorry, I thought this would be obvious. Let me rephrase, and assume version 8.3 instead of 100 for a more realistic version constraint.

Assuming you have any package that includes a "php" version constraint either directly or through its dependencies, I expect the following exit codes depending on the case:

  • the package can be installed with the PHP version (constraint) provided on the command line: exit code 0
  • the package cannot be installed with the PHP version (constraint) provided on the command line: exit code > 0 (and explanation why in the output)

As I said, right now I can only distinguish the two different outcomes right now by parsing the output which is neither elegant nor future-proof.

@Seldaek
Copy link
Member

Seldaek commented Jan 18, 2024

Ok so it's not about the warnings, but about whether why-not found a result or not. I see. Yeah that should be fixable fairly easily.

@Seldaek Seldaek added Feature and removed Support labels Jan 18, 2024
@Seldaek Seldaek added this to the 2.7 milestone Jan 18, 2024
@Seldaek Seldaek closed this as completed in 754f286 Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants