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
fix: drupal9 and drupal10 shouldn't be used with host-side drush so remove facility #5328
Conversation
Download the artifacts for this pull request:
See Testing a PR |
I agree that using Drush from the host is not best practice and this is a good PR. |
Just wondering... why is this not good practice? Just found out this issue after upgrading ddev to 1.22 as to why our drush scripts aren't working anymore... We were quite happy with using local drush with D9 / D10. It's actually a lot faster than using
Is there any way to bring this back? Thanks :) |
Oh, you want to use host-side drush still? All you have to do is add the removed stanza here to your settings.php or settings.local.php. When you use drush on the host side, you're depending on the host's version of php, and the host's version of drush, and it's just not a sustainable arrangement. It can cause lots of "interesting" behavior. In general, we encourage people to do everything repeatably inside the container, where the configuration is constrained. When you do this using host-side drush, every developer's experience can be different. But you can certainly just add this stanza to your settings.php/settings.local.php and be on the way! |
Thanks for your reply Rfay! In my experience, the host drush version matters little since it is only used to find the proper drush (most likely within /vendor/bin) and call it. So you always run the same version of drush in a composer-based setup. The only difference is what is used to launch drush. As far as php version goes... yes this is something the developer has to manage, i.e. matching it with the web container's php version. This is usually not a big issue... and can be solved with brew-php-switcher as needed. A tradeoff we are happy to make to save 8 seconds each time the cache is cleared! I was thinking of adding the code snippet as you suggest, but it seems actually a little tricky since it depends on the local port of the db container, and given this is adjusted dynamically by ddev:
From what I have observed, $port varies every time we start ddev... Do you think we would have to write a post-start command that would query ddev about the local port for the db container, then place this in settings.local.php? Hope you can suggest an easier fix :) |
For the port, use $DDEV_HOST_DB_PORT and it should be good. So something like
Unfortunately, I'm not sure your drush on the host side will know about that. I don't understand why you have performance problems when running drush inside the container. If you |
Thanks rfay, I am unable to locate the environment variable DDEV_HOST_DB_PORT on either the host or any of the web or database containers. However, I was able to get something working by creating a script that goes like this:
I feel this is not as robust as the original ddev functionality and it could probably be improved... You are right, mutagten speeds up the process. It is, however, very time-consuming to start on some projects. My tests indicate that enabling mutagen and opening a second shell with ddev ssh yields the same time results as running on the host. Still... we liked the simplicity of running drush from the host ;) Thanks for this great project, you and the ddev team really earned the 2023 Aaron Winborn Award! |
If you're having trouble starting up mutagen, it means that |
Thanks for all your help rfay... We are trying to patch things around to fix the departure of this feature, but I really wish this feature could be brought back into ddev if possible, as we also have issues with our git hooks no longer working. Was this feature causing problems elsewhere? |
Please open an issue with the specifics of your git hook problem. I don't know how it could have to do with DDEV. Please say in the issue whether you're using git inside the container or on the host. As mentioned above, you don't need DDEV to add this feature, you can just set it up in your settings.php. |
Could you please try out this new add-on?
And let me know how it goes? |
I tried it and it works great. Thanks @rfay |
@rfay this works very well and brings back the feature properly! Many thanks! |
I still would love to understand why there's a performance difference. Followups in please. I would love to know the answer. The only thing I can think is if drush is doing extensive things to sites/default/files. That could be tested by turning off the bind-mount of sites/default/files. |
The Issue
In Drupal7 and maybe early Drupal 8 it was common for people to run Drupal's drush (8) on the host side and so there was capability in the settings.ddev.php to allow this.
However, that's long since obsolete and just causes confusion now.
How This PR Solves The Issue
Remove the stanza from settings.ddev.php that set this up.
Manual Testing Instructions
Use DDEV with D9/D10. You should see a settings.ddev.php that doesn't have the stanza any more.
Automated Testing Overview
Related Issue Link(s)
Release/Deployment Notes