I installed Drush 8 with composer.
composer require drush/drush:~8
Unfortunately, error drush command not found after Drush completely installed.
Why's the drush command can't be use?
Installing Drush for Drupal 8 with Composer
I installed Drush 8 with composer.
composer require drush/drush:~8
Unfortunately, error drush command not found after Drush completely installed.
Why's the drush command can't be use?
Installing Drush for Drupal 8 with Composer
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.
I would recommend against installing Drush 9 via composer require at this time.
Thanks for the info!
Commented
Jul 11, 2016 at 4:31
composer require
?
composer global require
for anything, please see github.com/consolidation-org/cgr
Commented
Jul 24, 2016 at 22:00
~/.bashrc
might have been edited. Back it up and find a default one.
Commented
Apr 2, 2019 at 3:38
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.
code
export PATH="$HOME/.config/composer/vendor/bin:$PATH" code
. It help me solve my problem.
Commented
Aug 5, 2020 at 6:18
Anyone on Ubuntu 20.04?
I noticed composer installs not in ~/.composer/vendor/bin, but ~/.config/composer..
Super weird, since nobody has mentioned that (important) fact.
I am sure with the proper path sourced, it will work now..
I changed my $PATH in ~/.bashrc to ~/.config/composer/vendor/bin like this:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
..and it works!
export PATH="$HOME/.config/composer/vendor/bin/:$PATH"
, I found it so late :(
Commented
Jul 18, 2021 at 7:41
You need to make sure that drush
is located within your environmental PATH
variable, or you can specify installation folder by setting COMPOSER_BIN_DIR
, e.g.:
sudo COMPOSER_HOME=/var/lib/composer COMPOSER_BIN_DIR=/usr/local/bin COMPOSER_VENDOR_DIR=/var/lib/composer/vendor composer require drush/drush:~8
Or it's much easier to install it via Phar, e.g. on Linux:
sudo install <(curl http://files.drush.org/drush.phar) /usr/local/bin/drush
On OS X, try: brew install drush
.
Now, although my issues were with a Composer Scaffold install for Drupal 8 which needs Drush (in this case v.9) installed as a dependency, I too was having similar issues. Even though a global Drush is no longer recommended, due to dependency issues, it's very convenient to call upon Drush from anywhere.
What I would recommend installing is Drush Launcher, which will give you the option of calling Drush from anywhere, even if you are running different projects using different versions of Drush. I have it running both locally and on my Web servers, and it's running fine there. It fixed my issues of seeing drush: command not found
, even when I had projects where Composer had correctly installed Drush.
composer global require drush/drush:dev-master