1

I am trying to install Composer and Drush on my Mac for my Drupal website, but am running into an issue whenever I try to actually run a Drush command.

I followed these instructions to download and install composer and Drush, however, when I go to run a Drush command I get an error saying Drush is not found.

I believe the main issue is that export PATH="$HOME/.composer/vendor/bin:$PATH" does not work since my .composer directory doesn't have a vendor folder in it.

So somehow, when I ran brew install composer there was no vendor folder created, all that was created was a cache directory.

Why is the vendor folder missing after installing using brew?

BlondeSwan
  • 772
  • 5
  • 26
  • at least, add your code to get solutions from others. – Arphile Aug 20 '19 at 01:58
  • Which Drush? Starting from Drush 9 it only supports one install method now: That your Drupal 8 site is built with Composer and Drush listed as local dependency. You then can install [Drush Launcher](https://github.com/drush-ops/drush-launcher) to have a Drush command that always uses the right local Drush, or a global (Drush 8 maybe) fallback you can define. Have you also already tried to call your Drush directly? `cd /my/drupal/ && ~/.composer/vendor/drush/drush/drush status`? See https://docs.drush.org/en/master/install/ in general and the compatibility chart in special. – leymannx Aug 20 '19 at 04:56
  • @leymannx oops, I forgot to include that. I am actually using Drush 8.1.17 for a Drupal 7.63 project. – BlondeSwan Aug 20 '19 at 14:48

1 Answers1

2

Ensure composer is installed correctly

You have installed composer on your macOS system with the command:

brew install composer

Ensure composer is installed and found in your PATH by running:

which composer
composer --version

Installing drush

  1. Add composer's global bin-dir to your PATH environment variable

    export PATH="$(composer --global config --absolute bin-dir):${PATH}:"
    
  2. Install drush with the following command:

    composer global require drush/drush
    
  3. Verify drush has been installed correctly

    which drush
    drush --version
    

To persist the changes to your PATH add the line from 1. to your shell's startup files (i.e. ~/.bashrc for bash or ~/.zshrc for zsh). Afterwards start a new shell-session.

Nicolai Fröhlich
  • 51,330
  • 11
  • 126
  • 130
  • Thanks, these seemed to work somewhat, however, now my drush command fails with a `mysql command not found`. Does this relate to the Drush installation – BlondeSwan Aug 20 '19 at 16:22
  • You need to install the `mysql-client` package which contains the `mysql` and `mysqldump` binaries. If you're on a debian based system run `sudo apt-get install mysql-client` or run `brew install mysql-client` if you're on macOS. – Nicolai Fröhlich Aug 20 '19 at 16:34
  • Ah, turns out that I was missing an `export` in my .zshrc file to point to the mysql running through MAMP. – BlondeSwan Aug 20 '19 at 18:12
  • Also, your solution worked other than `--global` not being recognized. You just need `composer global require drush/drush` – BlondeSwan Aug 20 '19 at 18:13
  • I fixed the `s/--global/global/` issue in my answer. Thanks for pointing out. – Nicolai Fröhlich Aug 20 '19 at 18:34