Description

In my case this was caused by line endings. To fix it, run this:

sudo dos2unix vendor/drush/drush/drush

If this doesn't fix it, check other files as well, or maybe run this to do the same for all files in the current working dir:

sudo find . -type f -print0 | sudo xargs -0 dos2unix

Quite dumb.

Issues that this can cause, for search purposes:

  1. "/usr/bin/env: ‘php\r’: No such file or directory" error when trying to run drush
  2. other weird drush errors
  3. files in Git modifications that are not actually modified (line endings issue)
  4. Drupal (7?) theme hook parsing and discovery issues (ask me how I know, or don't if you have less than 10 hours)