How to fix Permission denied issue in Drush

If you see the following error in the deployment hook:

W: /bin/dash: 4: drush: Permission denied

Or this one when trying to run Drush:

-bash: /app/vendor/bin/drush: Permission denied

Then Drush is either not installed correctly or the permissions are not set.

First, check if Drush is present in composer.json. If not, run the following commands in your local environment:

composer config vendor-dir vendor
composer require drush/drush

If vendor/bin still does contain a symlink to Drush, you can try regenerating the entire vendor directory again:

rm -rf vendor
composer install

Alternatively, you can manually create the Drush symlink in vendor/bin as long as vendor/drush/drush/drush has already been installed using Composer:

cd vendor/bin 
ln -s drush ../drush/drush/drush