drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.33k stars 1.08k forks source link

Dependencies version constraints not applied when installing a new extension in an interactive request #6073

Open manueladan-nttdata opened 1 month ago

manueladan-nttdata commented 1 month ago

Describe the bug Drush pm:install doesn't take into account dependencies version restrictions of the extension to be installed.

To Reproduce In a fresh Drupal 10.3.1 installation (minimal profile) I created a new custom module named "test" with just the .info file as follows:

name: 'Test'
type: module
description: 'Just a test.'
package: Custom
core_version_requirement: ^10 || ^11
dependencies:
  - drupal:system (>=14.0)

It must not be possible to install since it requires a (not yet) existing version of Drupal core. From the extend administration UI I can not install it:

image

But drush allows me to do so:

# drush pm:install test
 [success] Successfully enabled: test

Expected behavior Drush shouldn't complete the Test module installation since its dependency on system >= 14.0 can not be satisfied.

Actual behavior As described.

Workaround Install extension throw the UI, but unfortunatelly extension installation is a common process where the UI is not involved (CI/CD ...)

System Configuration

Q A
Drush version? 12.5.2.0
Drupal version? 10.3.1
PHP version 8.2.15
OS? Linux

Additional information Add any other context about the problem here.

weitzman commented 1 month ago

I think this only throws the error for interactive requests. Non interactive are allowed to proceed. This went in at https://github.com/drush-ops/drush/pull/4733/files. Discussed at. https://github.com/drush-ops/drush/issues/6006#issue-2295751716

manueladan-nttdata commented 1 month ago

It seems to happen regardless the session is interactive or not:

Interactive (inside docker container launched with docker exec --interactive --tty ...):

image

Non-interactive:

image

weitzman commented 1 month ago

ok, perhaps someone can debug why interactive is not sufficient.

manueladan-nttdata commented 1 month ago

I was trying to address this. I'm not familiar with Drush internals, so this is an initial attempt. I worked in 12.x that matches my testing environment, it should moved into 13.x when done.

https://github.com/drush-ops/drush/compare/12.x...manueladan-nttdata:drush:6073-dependencies_version_constraints?expand=1

Output with this change:

image

weitzman commented 1 month ago

Help wanted, here.