Fixing Drush issues in DDEV

Sometimes drush cr does not work. A possible root for the issue could be the shebang

Check the shebang to confirm if the ^M is there:

ddev exec bash -lc 'head -1 vendor/bin/drush | cat -A' 

You should now see:

#!/usr/bin/env php$

If it shows ^M at the end, use Perl to convert CRLF → LF for the wrapper and make it executable:

ddev exec bash -lc "perl -pi -e 's/\r\n/\n/g' vendor/bin/drush && chmod +x vendor/

After this check the shebang again if the ^M is gone now.
If so try again to clear the cache by

ddev drush cr

Tags