Skip to content
Latchkey

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".

Drush
/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

  1. Run composer install so vendor/bin/drush exists.
  2. Invoke it by full path, or run from the project root.
  3. Pass --root/--uri if the docroot is a subdirectory.
Terminal
./vendor/bin/drush status --root=web

Add vendor/bin to PATH

Put the Composer bin directory on PATH so bare drush resolves to the site-local one.

Terminal
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_PATH once per job.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →