-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
drush.services.yml is picked even when requirements are not met #5600
Comments
Thanks for providing generator versions for everyone! As of last week, Drush 12 generators ignore any drush.services.yml. Use the create() method to get dependencies from the drupal container. This is great but it does make it harder to do this multiple versions thing. Maybe @greg-1-anderson has an idea besides your clever workaround. Docs are at https://www.drush.org/12.x/generators/ |
I think my preference for version-specific commands and generators would be to use a different major version for your module / library for each version of Drupal that you support, and use a |
I don't think that approach works well anymore. Drupal modules routinely span Drupal versions. The OP wants to span multiple versions of Drush (actually DCG), not Drupal. Unlike commands, the Generator API is now on v3, in just a few years. |
Do you think I should open an issue in DCG to figure out how to support v2 and v3 at the same time in the same branch of a module? |
I think we can use this very issue, since Drush's implementation of DCG is a big factor. Ping @Chi-teck |
Does this work this way in Drush 12.0.0-RC3 ? |
Yes. |
The same technique should work fine, if you use different major version for your module / library for each version of DCG that you support, and then use |
That means that if a module like |
OK you're right, that's not great, because you'd otherwise want the rest of the module to be the same between the major versions.
Which of these options sounds best to folks? |
The above options are not relevant if we come up with a good way for the same command file to support multiple major versions of DCG. |
The issue summary raises a valid question. Why does Drush load services file when its requirements are not net? If we could ignore drush11.services.yml, then it wouldn't be a problem to support multiple versions of DCG simultaneously. The other possible approach is not loading services tagged with |
Drush stopped ignoring the version constraints on the default services file, |
I dont especially want to re-introduce that. For anyone who isn't satisfied with the workaround in this issue, fix Drush 11 constraint handling so that |
How about this way? See #5605. |
So, if we just merge #5605, then we never backport static factory create support for generators to Drush 11, and folks can then use static create in Drush 12 / DCG 3, and drush.services.yml with the tag drush.generator.v2 in Drush 11 / DCG 2? And we worry about how to handle DCG 4 when it happens? |
With that PR I don't think the issue in the title needs a fix since drush.services.yml will be deprecated anyway |
Describe the bug
Specifying a
drush.services.yml
file in thecomposer.json
of a Drupal module with a restriction that is not fulfilled (such as^999
) loads the classes regardless.To Reproduce
Change the restriction in a composer.json file of a module to
^999
and verify the commands defined in thedrush.services.yml
are still loaded.Expected behavior
The
drush.services.yml
is ignoredActual behavior
The commands in the
drush.services.yml
file are loadedWorkaround
Specify an non-existing yml.
System Configuration
Additional information
I'm trying to provide a backwards compatible way to add v3 generators to the
extra_field
Drupal modulehttps://git.drupalcode.org/project/extra_field/-/blob/8.x-2.x/drush.services.yml
and I'm looking for a way to ignore the v1 and v2 generators. I think I'm going to use the workaround so far but I found the behavior odd.
It is probably not an easy fix since many Drupal modules declare the services file with something like
"drush.services.yml": "^10"
but that won't match drush 11 but currently it works for drush 11 because one of the files is always picked.The text was updated successfully, but these errors were encountered: