Problem/Motivation
For most practical cases, new Drupal 9 project is started with
composer create-project drupal/recommended-project
composer require drush/drush
Adding drush/drush as a dependency to drupal/recommended-project saves the second step.
Since composer create-project is a one-off operation, it is easy to opt out of using drush with
composer remove drush/drush
Proposed resolution
Add drush/drush to composer/Template/RecommendedProject/composer.json
The Drush maintainers have agreed to coordinate closely with the Drupal Release Management and Security teams.
Please see these slides from a Drupalcon Global 2020 presentation. It list more benefits and considerations.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | drush-in-recommended-project-3159647-d9.patch | 595 bytes | jcnventura |
Comments
Comment #1
jcnventurajcnventura created an issue.
Comment #2
heddnhttps://git.drupalcode.org/project/drupal/-/tree/9.0.x/composer/Template... is where we'd file a patch.
Comment #3
jeroentComment #4
hussainwebI don't have strong opinions because this is just a template. I think it makes sense for it to be in a template we recommend for anyone to begin.
Comment #5
jcnventuraThe patch is easy enough
Comment #6
hussainwebThe patch should work because
DrupalCoreRecommendedBuilder::getPackage()would not remove anything. Still, I am not sure if the tests would pass. Shouldn't this issue be in Drupal project queue for tests to run?Comment #7
jcnventuraYeah, it was moved out of the core project while I wrote the patch. This is hardly an initative, unlike the related issue I'm adding which would create a drush-in-core replacement.
Comment #8
moshe weitzman commentedComment #9
valthebaldComment #10
jcnventuraAnother point in favour of this proposal is that a few lines below, drupal/recommended-project already specifies this:
Comment #11
moshe weitzman commentedComment #12
markdorisonBased on Moshe's DrupalCon presentation, I think this change makes a great deal of sense.
Comment #13
rodrigoaguileraHaving drush into the template for starting projects will cover many use cases and as the slides point out folks can always opt out of including drush.
Comment #14
RedLucas25 commentedI suppose now we wait for if anybody is against this...
I am also for the patch!
Comment #15
tim.plunkettFix https://github.com/drush-ops/drush/pull/3645 first.
We must continue to hold the maintainers of dependencies to higher standards. See also: blacklist/whitelist, master/slave.
Comment #16
partyka commentedI was able to test successfully by:
I think having this as part of the recommended settings makes a lot of sense.
Comment #17
greg.1.anderson commentedI am +1 on adding drush/drush to drupal/recommended-project.
We probably should not add it to drupal/legacy-project, though, as doing that would cause Drush to end up in the Drupal downloads, and I don't think we want that at this point.
drupal/legacy-project is implicitly out of scope here, since it was never mentioned and is not in the patch; I thought it was worth explicitly mentioning though.
Comment #18
greg.1.anderson commentedThe patch still needs work, though; if we have drush/drush in the Project template, then we should also have a simple build test that confirms that Drush is usable from the installed project. Just running a few commands would be sufficient; no need to try to run the Drush test suite or anything lengthy like that.
Comment #19
larowlanAlso, this is in the ideas queue, so patches will go somewhere else.
Comment #20
xjmFWIW I'm not totally in favor of this. It privileges one CLI tool over others, and we continue to run into compatibility issues with different Drush versions from time to time. I'd prefer to add more commands to core itself.
Comment #21
xjmComment #22
larowlanfor reference, there is only one tool compatible with D9 at this point in time
Comment #23
wizonesolutionsI'm OK with privileging Drush. This is recommended-project, not core-recommended. People can opt out by running
composer remove drush/drush.It would save a lot of time versus developing a home-grown Drupal CLI tool.
Comment #24
partyka commentedIs there already a framework for a CLI tool in core .. or at least work on one?
Comment #25
larowlan@partyka yep, reference
php core/scripts/drupal quick-startin your list above 💪 and see #3089277: Provide core CLI commands for the most common features of DrushComment #26
jcnventuraTo complement @larowlan's point in #22, and for those that didn't bother to open @moshe weitzman's slides (linked in the Issue Summary), this is a tweet from Jesus Olivas, replying to @wizonesolutions' questioning whether Drupal console was dead: (https://twitter.com/jmolivas/status/1258034064155529218)
I think it means that console is effectively dead, and if the code-generation capabilities of Drush continue to improve, it might never exit the mentioned hiatus.
I don't believe that adding Drush to the recommended-project at this time prevents the development of core-cli. We can easily remove it sometime in the future, no need to warn about BC-breaks for something that can't be updated, and is only used at the start of a new project. Not adding it, while waiting for the future solution will make people continue to prefer to use drupal-composer/drupal-project, at least for Drupal 8.
Comment #27
xmacinfoI agree. We now have a single CLI tool. And Drush is now mature and I do not experience any compatibility version issue anymore.
Also, Drush is the official the facto CLI tool for Drupal on most devops workflow.
Comment #28
fathershawnIt seems to me that a principle change of perspective we brought to D8 was, "we don't have to build it if there's already an excellent solution." We have a well crafted Symfony Console app in drush. Including it in the recommended project is completely in line with our development philosophy.
Comment #29
aaronmchaleOverall I agree with this, I do think #3089277: Provide core CLI commands for the most common features of Drush is the best option in the long run, but as an intermediate solution this would be a great addition for the recommended project template.
Comment #30
rkelbel48 commented+1 for the patch!
This was a great discussion at DrupalCon and I see no reason not to do this. As mentioned, Drush is matured and capable and the ability to opt out is very simple.
Comment #31
norman.lolI agree with #15 that this maybe is a good timing to address https://github.com/drush-ops/drush/issues/3645 and also replace blacklist/whitelist or master with more appropriate words (blocklist/allowlist and main). I mean, look at the Driesnote again and let's take what Dries said about diversity and inclusion seriously, right now.
I also want to highlight one thing Moshe said in a subclause during the Q+A about possible complications during the process to get Drush into the recommended template. He said: The technics is not the problem, the people are. (Referring to the discussions that need to take place beforehand). And of course "people" also includes him and the current maintainers of Drush and their willingness to address mentioned issue for example.
Comment #32
greg.1.anderson commentedre #31, I am still in favor of doing #3647, although it is too late to remove the option from Drush 10.
"Blacklist" appears only once in Drush 10, as a comment; this would be trivial to remove. "Whitelist" is used only in one option name (sql sanitize), so I think this would also be really easy to alias and deprecate.
There are no references to "slave" in the Drush repository. There are many references to "master", but I believe they are all referring to the default branch.
I think it would be pretty easy to rename our master branch to 10.x or main. I have already renamed the default branch for all of the Consolidation projects to "main".
I agree that now is a good time to step up to the plate and address D&I issues. We should create issues and/or PRs in the Drush queue to discuss and implement. I created #4468 for the default branch issue.
Comment #33
damienmckenna@greg.1.anderson: Thank you for the updates. If you're in favor of #3647/#3645 could you please unlock them so we can collaborate on replacements?
Comment #34
norman.lolThanks @greg.1.anderson for the updates. I opened https://github.com/drush-ops/drush/pull/4469 to replace blacklist/whitelist.
Comment #35
hansfn commentedJust added a related issue which show that at least once Drush caused problems when upgrading. (This might not never happen again so just ignore this comment if is irrelevant.)
Comment #36
jcnventura@hansfn Maybe we should make clear that an upgrade of the drupal/core-recommended project should also upgrade the symfony/* packages. This was already a recommendation for updating drupal-composer/drupal-project before (
composer update drupal/core webflo/drupal-core-require-dev "symfony/*" --with-dependencies).Comment #37
hansfn commentedI don't think we should have that discussion here - it would side track the issue. Maybe create a new issue if it doesn't already exist. (Whether or not we should include "symfony/*" in the update command has been discussed a lot on the actual documentation pages. I find it very sad that we can't recommend one, simple command.)
I merely wanted to point out that adding drush/drush has side effects.
Comment #38
greg.1.anderson commentedRegarding #35, if we actually added drush/drush to drush/core-recommended, then we could also add a test that would tell us immediately if a patch updated a dependency that made Drupal's locked dependencies incompatible with Drush. Then we could fix Drush before Drupal was released.
(I actually think that the current tests would probably already catch this, but I haven't tried.)
Comment #39
ressaTesting Drush beforehand sounds great @greg.1.anderson, adding my own related issue. It is about Drush 8, but the method could be used for Drush 10 as well.
Comment #40
norman.lolHappy to see https://github.com/drush-ops/drush/pull/4469 already got merged into master. 🎉
Comment #41
greg.1.anderson commentedI'll convert the master branch to the 10.x branch pretty soon.
Comment #42
hansfn commentedBy the way, I strongly support adding drush/drush to drupal/recommended-project.
Comment #43
ressa+1 for adding Drush in the recommended Drupal project, like I commented in #3085578: No Drush in Drupal 8.8 composer-ready project templates?.
Comment #44
norman.lolOkay, so the last time we set the issue to needs work was when we decided we need tests to verify that Drush is working. Like calling
../vendor/bin/drush cron an installed site or just../vendor/bin/drush cc drush?How do we proceed now?
Comment #45
jcnventuraThis is Drupal core ideas. There should be no patches or tests here. I know I created a patch back in #5, but in my defense, creating and testing that patch was took me 14 minutes between creating this issue and posting the patch, and in the meantime it was moved out of the Drupal core project.
I think the next step would be to get an OK from the release and framework managers, and then we could maybe create a new issue and add tests to it.
Comment #46
MixologicSo the primary sticking point, in my mind, is that Drush shares a significant number of third party dependencies with drupal core (mostly symfony deps).
What that means is that during the core development lifecycle, we will likely run into situations where core needs to bump their dependencies, like, say, before a minor release, and drush has not yet bumped/tested with those new deps. Which means there will either be a delay or lag where an issue gets filed with drush to fix them there first, so that we can then fix the deps in core. For most minors this likely wont be too big of an issue.
This will mainly be an issue when bumping major versions (say, symfony 4 to 5 etc). This is exactly why drupal/console no longer works with drupal 9.
One way to solve that problem that removes any blockers to core progress is to remove drush from the template if/when we ever get into a situation where we're unable to update core's dependencies because of drush's dependencies. And then add it back into the template once drush becomes compatible again.
However, there is also the sort of underlying reality that we probably should not consider a Drupal release to be complete without drush(cli) support, as it is a defacto feature of core that just so happens to be managed outside the core process.
I feel like the way the way forward is for Drush maintainers and the Release managers to have some agreement/policy in place that yields the least possible strife for all involved parties.
Comment #47
moshe weitzman commented100% agree. Thats what I meant in the OP "The Drush maintainers have agreed to coordinate closely with the Drupal Release Management and Security teams." I also said it in the Drupalcon presentation linked from the OP. For now, this a good faith agreement from the Drush maintainers. I'm happy to agree to any more formal version once thats developed. IMO that formal version need not block this issue.
Comment #48
tormi+1 to add Drush to the drupal/recommended-project template.
Comment #49
ressaTwo years have passed since the last comment, and Drush has only gotten more stable since then.
If what is necessary for this to move forward, is that Drush maintainers and Drupal Release managers has some agreement/policy in place that yields the least possible strife for all involved parties, perhaps this can be revisited now, and formalized?
Comment #50
mile23+1 on #46, because the question is: Will release managers for core delay a release if Drush isn't ready yet? I'm not sure what the right answer is to that question.
Assuming we're doing it, this issue should:
drush/drushto both thedrupal/recommended-projectanddrupal/legacy-projecttemplates.Drupal\BuildTests\Composer\Template\ComposerProjectTemplatesTestfails ifdrush/drushcan't be installed for whatever reason. A failing test here could be generated by requiringdrush/drush:^999, for instance.Drupal\BuildTests\Composer\Template\ComposerProjectTemplatesTestto try and get output from Drush, ideally without needing a database or whatever...drush listwould be fine.We don't have this much diligence around the current third-party dependencies such as
cweagans/composer-patches, and maybe we should. But it's also true that those Composer plugins aren't so closely tied to our runtime or dev process the way Drush is.Comment #51
solideogloria commentedIs the end goal just to include Drush as a dependency, or would it be to eventually have the Drush project itself become part of Core, such that there is a "Drush module" or something similar?
Comment #52
jcnventuraThe idea is to just add it as a dependency in the
drupal/recommended-project. This would not change Drupal core in any way, other than that the recommended project would now add Drush if not modified. Of course, any site-builder that doesn't want to use Drush would always be free to remove it. Like everyone is already free to removedrupal/core-project-messageordrupal/core-dev.Comment #53
ressaIt looks like you have to uninstall Drush in order to update from Drupal 9 to Drupal 10: Can't update from Drupal 9 to Drupal 10 with Drush installed #5461.
My hunch is that this situation could have been avoided, if Drush was in core, due to tighter integration?
Comment #54
ressaMy assumption that Drush was that cause was wrong, which @moshe weitzman helped me realize. Following the steps on the upgrading Drupal 9 to Drupal 10 documentation page, the process completes without a hitch.
Comment #55
xjmThis issue came up when discussing #3082230-50: [meta] Convert some tests to Build tests and #3377980: Add BuildTest for testing update using Drush.
The thing is, I don't think that agreement is actually there from the release management and Security Team side (speaking as a member of both groups).
I would much prefer to add core commands for the most basic usecases of Drush (similar to the
quick-startcommand), but leave Drush to handle advanced usecases, and not add a dependency to any core templates.#50 raises the relevant point: Would we delay a core release for Drush? The answer of that is "No" from my perspective.
Maybe there are compromises we could consider, like adding it to the suggestions that Composer gives you when you install core?
I agree with #15 also.
Comment #56
moshe weitzman commentedWe don't need to choose. We can add Drush to drupal/recommended-project AND keep adding commands to Drupal core. As core adds commands, the commands get removed from Drush. This improves out of the box experience and preserves core's autonomy to make the CLI experience it wants. Of course this requires some good faith co-operation, which I think we are all committed to.
Comment #57
longwaveI am weak -1 to this, for the reasons given in #46. When we (perhaps inadvertently) break Drush because of a change we want to make to Drupal core, whose responsibility is it to fix? If we start adding test coverage to ensure Drush runs against HEAD as in #50, what happens when an issue proposes a change that means that test starts failing? What happens if this is the case for a minor release?
To me the separation is a good thing and means that the Drush team can develop multiple majors concurrently and release them on their own schedule as they see fit. Adding Drush to a new project is already simple enough.
Comment #58
moshe weitzman commentedComment #59
xmacinfoI agree 100% with #56 and #58.
Let’s get this move forward. Let’s add
drush/drushto thedrupal/recommendedcomposer file.For another issue discussion, though, which command will we register in the command-line?
$ drushfor Drush$ drupalfor Drupal console (not maintained anymore)Can we hijack
$ drupalfor the new core CLI commands?Comment #60
xjm@longwave suggested a
suggestentry instead, which I would also be fine with, especially currently when core doesn't include the minimum necessary commands.@xmacinfo, it's not just a matter of "getting it moving forward". The IS states agreement with the release managers and Security Team, but no such agreement actually exists. There isn't any point in creating an MR for it before it does.
Comment #61
xmacinfosuggestsupports only text and not version numbers. But at this point, a developer can install any version of Drush that support his Drupal installation and not a specific version.But I feel we will quickly move to
drupal-recommendedas soon as we add code that needs Drush.Comment #62
aaronmchale100% agree with this.
I would love to see the
drupalcli script/executable gain more commands, for things like user and cache management. If in core we make a real effort to grow whatdrupalcli does, then I'd hope a contrib ecosystem would start to build up around it. With contrib modules providing their own commands. Maybe eventually what remains in Drush is just a contrib project that supplementsdrupalwith more commands (just a thought).One of the nice things from a dev/dev-ops perspective of other frameworks, like Django, which make heavy use of an out-of-the-box cli tool is it makes that experience a bit more enjoyable. So, by putting efforts into enhancing the
drupalcli we would be enhancing the overall appeal of Drupal.I'm not saying that Drush doesn't do that, Drush is excellent and I think we can all be thankful that it exists, but by not having most of the common commands in Core, we make that barrier to entry slightly higher for new people evaluating Drupal, they might not even know about Drush, they might just assume Drupal doesn't have very good cli tools and move on.
I'll admit this is starting to sound like I'm advocating for adding Drush to the recommended project template, but really I'm not. I'm advocating for bringing more of what Drush does really well into Core. In part because of what has already been said and the challenges that adding Drush to the template could introduce, but also because if we add Drush that kind of feels like we're saying that is "good enough", and we may never then make an effort to improve the
drupalcli tool. At the very least, not having Drush in the template gives us all a bit of motivation to one day have those common commands in Core out-of-the-box.Comment #63
solideogloria commentedI'm not sure which is best. But I just hope, for whatever attempt is made to include commands, that it doesn't become the next unmaintained Drupal console. Personally, I like that
drushdoes it all, and I don't want to see half of the commands I want in some other utility, where I suddenly have to remember whether it'sdrush user:loginordrupal user:login.Comment #64
markdorisonI could not agree more. Drush is fantastic and we should continue to leverage that in the best way possible, which I believe is the motivation behind this issue. Whatever the outcome, I hope we continue to leverage and support the great work that the Drush maintainers do for this community.
Comment #65
norman.lolYeah, rebuilding stuff that already exists in Drush and then needing to maintain this rebuilt stuff doesn't sound DRY to me. Instead we should unify efforts to add Drush closer to the Drupal ecosystem.
Comment #66
aaronmchaleJust for some context, there is already an existing "Drupal CLI" included with Drupal Core, you can find it at
core/scripts/drupal, it's based on Symfony Console, which is what Drush is also based on, so the look and feel of it (colors) as well as the way commands work is pretty much the same as Drush. Adding more commands to it would be quite straightforward, it currently includes commands such asgenerate-themeandquick-start. I believe contrib could also add their own commands.Comment #67
ressaUntil a decision is made, is #3405516: Document how to most easily make vendor/bin/drush available as drush possible?
Comment #68
catchdrush is a dependency of Drupal CMS so moving this to the core queue.
Comment #69
phenaproximaDrush is not really a "dependency" of Drupal CMS per se. Our project template includes it because Drush is an essential tool, to the point where you can safely assume that any Drupalist you talk to is using it.
As of a couple days ago, Drush is now a dev dependency of Drupal CMS's regular project template (
drupal/cms), and is not included with its cPanel-specific project template (drupal/cms_cpanel).