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

Add prompt to require command if a package name is not found but there are similar names that could be used #11284

Merged
merged 1 commit into from
Jun 23, 2023

Conversation

Seldaek
Copy link
Member

@Seldaek Seldaek commented Jan 27, 2023

Fixes #11279

cc @staabm

@Seldaek Seldaek added this to the 2.6 milestone Jan 27, 2023
@staabm
Copy link
Contributor

staabm commented Jan 27, 2023

tested locally. the happy path looks good.

but a few nits:

  • leaving it empty runs into a Value "" is invalid error
mstaab@NB-COMPLEX-45 MINGW64 /c/dvl/Workspace/composer (pr/11284)
$ php bin/composer require phpunit
Info from https://repo.packagist.org: #StandWithUkraine
Could not find package phpunit.
Pick one of these or leave empty to abort:
  [0] phpunit/phpunit
  [1] phpunit/php-timer
  [2] phpunit/php-invoker
  [3] brianium/paratest
  [4] yoast/phpunit-polyfills
 >

  Value "" is invalid


require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-
dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-
prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>...]

  • choosing 0, so phpunit/phpunit returns a error that it cannot be installed because requirements are not met. composer still asks me whether I want to use --dev - even though its clear that it cannot be installed?
mstaab@NB-COMPLEX-45 MINGW64 /c/dvl/Workspace/composer (pr/11284)
$ php bin/composer require phpunit
Could not find package phpunit.
Pick one of these or leave empty to abort:
  [0] phpunit/phpunit
  [1] phpunit/php-timer
  [2] phpunit/php-invoker
  [3] brianium/paratest
  [4] yoast/phpunit-polyfills
 > 0
0
Cannot use phpunit/phpunit's latest version 9.5.28 as it requires php >=7.3 which is not satisfied by your platform.
The package you required is recommended to be placed in require-dev (because it is tagged as "testing") but you did not use --dev.

Do you want to re-run the command with --dev? [yes]?

thank you!

@Seldaek
Copy link
Member Author

Seldaek commented Jan 27, 2023

Regarding the second one, the Cannot use phpunit/phpunit's latest version 9.5.28 as it requires php >=7.3 which is not satisfied by your platform. bit is just a warning that the latest version cannot be used, but it asks because it will end up using another lower version that works with your PHP.

The first one yes saw it too but I am not sure how to fix this for just "", you kinda want an error if you enter any other invalid value though.

@staabm
Copy link
Contributor

staabm commented Jan 27, 2023

Regarding the second one, the Cannot use phpunit/phpunit's latest version 9.5.28 as it requires php >=7.3 which is not satisfied by your platform. bit is just a warning that the latest version cannot be used, but it asks because it will end up using another lower version that works with your PHP.

I see.

The first one yes saw it too but I am not sure how to fix this for just "", you kinda want an error if you enter any other invalid value though.

yeah - maybe its good enough. a error message like "aborting.." or similar might be better.

telling the user that he may leave it blank to abort and afterwards sending a error that blank input is a error might be a bit misleading :).

no that important details though.

@stof
Copy link
Contributor

stof commented Jan 27, 2023

To abort a composer require, you can instead abort the command in the native way: with Ctrl+C

@Seldaek Seldaek merged commit 1db0a47 into composer:main Jun 23, 2023
@staabm
Copy link
Contributor

staabm commented Jun 23, 2023

thanks

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

Successfully merging this pull request may close these issues.

interactive composer require
3 participants