4

I've been using Drupal for several years, but only just dipping a toe in with Drush - I've bought an ebook tutorial and working my way through. I've installed Composer, and used it to install Drush. The tutorial book specified a particular build of Drush to install (7.0.0-alpha5). I've navigated to a drupal folder and run

drush st 

to get installation info which works fine. The tutorial explains that you don't have to navigate into the drupal folder to do this, instead using

drush --root=PATH-TO-DRUPAL-SITE st

however this brings an error:

Fatal error: Call to undefined function conf_path()

Googling this error suggests this a problem with the version of Drush and to upgrade.

SO I've navigated into the .composer/vendor/drush/drush folder and run composer global update but composer says nothing to update, confirming the version as 7.0.0-alpha5 - I assume this is not the latest 7.x version, so do I need something changing in the composer.json file?

1
  • "Drush only supports one install method. It requires that your Drupal site be built with Composer and Drush be listed as a dependency" according to the official Drush docs at docs.drush.org/en/master/install --things may have evolved since the comment @JohnDoea wrote a few years ago. Note the advent of Drush Launcher and the role it plays in update efforts.
    – Kay V
    Commented Dec 16, 2019 at 10:56

3 Answers 3

12

If you want to update your global installations of any package under composer, you can just do this:

composer global update

You don't need to navigate to .composer/vendor/drush/drush

However: There are a couple of things:

1) Your global composer.json file might have a version constraint.

Check out drush's packagist page: https://packagist.org/packages/drush/drush

That will show you the available release versions of drush.

Edit ~/.composer/composer.json so that the version constraint for drush/drush is higher than the one you have. Probably something like "~8".

Do composer global update.

2) It's best practice to install drush per project.

The reasons why are a little complex and might not answer the question here, so I'll just link to an article: https://pantheon.io/blog/composer-vs-drush-make-which-should-you-use

1
  • Thanks paul-m - editing that composer.json rather than the one inside drush/drush did the job, updated to 7.4 for now, which got rid of the error. I'll look at your suggestion on point 2 as well, just want to follow this tutorial for now so I understand it all a bit better.
    – iain-g
    Commented Dec 5, 2016 at 17:02
3

I would add that, depending upon your needs, composer global update may not bring you up to the version you need. I had run it, and was only getting to version 8.1.8.

For my needs, I needed 8.1.14, at minimum. Since the latest stable version was 8.1.15 as of now, I simply ran this: composer require drush/drush:8.1.15. This ran fine, and then checking by drush --version, which registered the proper version then.

1

To update Drush using composer, navigate to your project root, then use

composer update drush/drush

Note that the method for installing and running Drush has changed pretty significantly (I believe as of the release of Drush 9). Fortunately managing Drush is now much less unique to Drush and much more like what you do with other software.

See the official docs: Install a site-local Drush and Drush Launcher

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.