Information for: DEVELOPERS   PARTNERS

About Drush on Cloud Platform

This page is for applications running Drupal 8 or greater. For information about Drush and Drupal 7, see Drush and Drupal 7 on Cloud Platform.

Drush is a command-line shell for Drupal, which you can require as part of your Composer-built Drupal website. With Drush, you can perform administrative and application maintenance tasks from the command line instead of Drupal’s administrative interface.

Local development best practices

Acquia recommends you develop your codebase locally, using Composer to build your codebase, and Dev Desktop to sync your code between your local environment and Cloud Platform, rather than attempting to manage code or modules remotely on Cloud Platform.

You can change your application’s code, use Drush locally to install or update modules, and then send the changes to Cloud Platform using version control or Dev Desktop.

Note

Run Drush commands from your website’s docroot.

Using Drush on Cloud Platform

Although multiple versions of Drush (Drush 6 to Drush 10) are pre-installed on Cloud Platform, 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. It is dangerous to run the globally-installed version of Drush because the behavior of your cron jobs, Cloud Hooks, or other automated scripts may change unexpectedly when a new version of Drush becomes the default.

Drush commands not specifying a version of Drush will default to Drush 8.

You can use Drush with your applications after you enable SSH access to connect to Cloud Platform using SSH.

Drush versions and Drupal 8 or greater

  • Although Drush 9 and Drush 10 are available for use, Acquia doesn’t recommend their use with Drupal releases prior to Drupal 8.5. Drush 8 is the only fully supported version of Drush for Cloud Platform for Drupal releases prior to Drupal 8.5. Drush 10 is the only fully supported version of Drush for Drupal releases since Drupal 9.
  • To use Drush 9 or Drush 10, depending on which version of Drupal your application is running, one or other other must be installed as a project dependency (using Composer). These versions of Drush no longer include a global install command.

Specifying a version of Drush in commands

To run a specific version of Drush, specify the major version in the drush command. For example, to run Drush 7, use the command drush7.

If you want to change your personal default Drush version, you can set an alias for drush in a .bashrc file. For example, to make the drush command run Drush 7 on interactive bash commands, add the following line to your ~/.bashrc file:

alias drush=drush7

This alias will have no effect during cron jobs or Cloud Hooks. To use a specific version of Drush in a cron command, you must call it directly, as in the following example:

/usr/local/bin/drush7

When you run Drush on your local machine and use a remote Drush alias for your Cloud Platform application (such as those described in Using Drush aliases), the remote Drush command cannot check for a site-local version of Drush, and will instead run the default version of Drush on Cloud Platform.

Acquia recommends you run Drush commands by specifying the application, replacing [site] with your sitename and [env] with your environment, as in the following example:

drush --root=/var/www/html/[site].[env]/docroot

To run a specific version of Drush on Cloud Platform when you use a remote alias, edit the alias file in the $HOME/.drush folder on your local machine to specify the version you want. For example:

$aliases['dev'] = array(
  'path-aliases' => array(
    '%drush-script' => 'drush7',
  ),
  // ... other alias settings here
);

Finding help for Drush

To access help for Drush online, go to Drush Commands.

To view command-line help, enter the command appropriate to your version of Drush on the command line while signed in to your Cloud Platform server:

  • Drush 8: drush8 help
  • Drush 9: drush9 list for a list of commands, or drush9 help [command name] for help for a specific command