Drupal - Drush command not found after Drush completely installed
Once you have installed Drush, you need to ensure that you ~/vendor/bin directory is in your $PATH, as explained in the installation instructions (Note: this link no longer works)
Add export PATH="$HOME/.composer/vendor/bin:$PATH"
to your ~/.bash_profile or ~/.bashrc, and then run source ~/.bash_profile
(or ~/.bashrc).
I would recommend against installing Drush 9 via composer require
at this time. Sticking with Drush 8 is probably best; if you want to use Drush 9, use a simpler installation method, such downloading the .phar, or clone the repository and run composer install
in the directory Drush was cloned to.
Using ssh on my server host I did add drush to my path following composer instructions: Add
export PATH="$HOME/.composer/vendor/bin:$PATH"
to your ~/.bash_profile or ~/.bashrc, and then run source ~/.bash_profile (or ~/.bashrc)
However, I got this running
drush status
-bash: drush: command not found
which composer
/opt/cpanel/composer/bin/composer
which drush
/usr/bin/which: no drush in (/home/mth/.composer/vendor/bin:/home/mth/.composer/vendor/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/cpanel/composer/bin:/home/mth/bin:/home/mth/bin)
Using my cPanel file manager, I found I couldn't see the hidden composer folder, though I saw other hidden folders and files (dot prefix). It turns out composer was within the .config folder. I added the new folder to my $PATH and bingo!
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
Hours! Moral? Verify composer location.