Drupal "drush: command not found" / "could not be found" in CI
Modern Drupal ships Drush as a Composer dependency at vendor/bin/drush, not globally. In CI a bare drush either is not on PATH, or a stale global Drush runs and cannot find the site, reporting the command could not be found.
What this error means
A drush ... step fails with "drush: command not found" (exit 127), or a global drush prints "The drush command '<cmd>' could not be found. Drush was unable to load a Drupal site".
/home/runner/work/_temp/script.sh: line 1: drush: command not found
Error: Process completed with exit code 127.Common causes
The site-local Drush is not on PATH
Composer installs Drush to vendor/bin/drush, which is not on the runner PATH, so a bare drush is unresolved.
A global Drush runs outside the Drupal root
A globally installed Drush cannot bootstrap the site from the wrong directory, so it reports the command could not be found.
How to fix it
Call the vendored Drush from the Drupal root
- Run
composer installsovendor/bin/drushexists. - Invoke it by full path, or run from the project root.
- Pass
--root/--uriif the docroot is a subdirectory.
./vendor/bin/drush status --root=webAdd vendor/bin to PATH
Put the Composer bin directory on PATH so bare drush resolves to the site-local one.
echo "$GITHUB_WORKSPACE/vendor/bin" >> "$GITHUB_PATH"How to prevent it
- Always use
vendor/bin/drush, never a global Drush, in CI. - Run drush from the project root or pass
--root. - Add the Composer bin path to
GITHUB_PATHonce per job.