Loading...


Related Products


Date Published: February 11, 2022

Using a newer version of drush globaly

Warning

Please note that this is a workaround for emergency situations only! It is absolutely not recommended best practice. There are known issues when installing Drush in the home directory.

Installing Drush in your user directory can cause unexpected task failures. Acquia recommends you require a site-local Drush as part of your codebase, not your home directory, and run your commands with a specific major version of Drush, as described in Using Drush on Cloud Platform.

This is a workaround if you absolutely need to run newer versions of drush commands manually without requiring drush in your project directly. This is NOT a permanent solution.

Having provided adequate warning here are the steps you will need to take.

First install composer on the environment home directory and require drush :

site@instance-xxx:/var/www/html/site.env/docroot$ cd ~
site@instance-xxx:~$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
site@instance-xxx:~$ php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
site@instance-xxx:~$ php composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 2.1.6) successfully installed to: /mnt/gfs/home/site/composer.phar
Use it: php composer.phar

site@instance-xxx:~$ php -r "unlink('composer-setup.php');"
site@instance-xxx:~$ php composer.phar require drush/drush

... that will install the latest version of drush  in /home/[sitename]/vendor/drush.

IF there is NO drush required in your repository  then you can add the drush you just installed to the start of the $PATH with:

$ echo 'export PATH="$HOME/vendor/drush/drush:$PATH"' >> ~/.bashrc

Once that is done you can run drush normally and the latest version should be picked up instead of the global one.

We strongly urge you to leave a README.txt in your home folder with the steps taken in this ticket for future reference as well as only performing the above steps when absolutely necessary and reverting them as soon as possible!!

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation