This proved much more difficult than it should have been, so I wrote this article.
$ drush --version
Install Drush globally
The after installing Drush 10, the “Drush version” command would work anywhere except inside a Drupal instance, useless I know. I kept getting this error whenever I ran “drush xxx”, “[warning] Drush command terminated abnormally.”. I eventually I removed Drush 10 and installed Drush 9, problem solved.
composer global require drush/drush:9.x
Code language: PHP (php)
Add path to .bash_profile
# edit .bash_profile
$ nano ~/.bash_profile
# add this line
PATH=$HOME/.config/composer/vendor/bin:$PATH
# use newly modified .bash_profile
$ source ~/.bash_profile
Code language: PHP (php)
Update Drush globally
$ composer global update drush/drush
Code language: PHP (php)
Uninstall Drush
Maybe you will need this too.
$ composer global remove drush/drush
Code language: PHP (php)
Alternate
composer require drush/drush
Code language: JavaScript (javascript)
Troubleshooting
Error: “[warning] Drush command terminated abnormally.”
Was fixed by changing to a different version of Drush.