0

I have been tasked with updating my code shop's long-abandoned Drupal 7 codebase to the most recent Drupal core, in order to bring in the latest security fixes (it's currently using v7.67). But all the knowledge I had about how to use drush seems to now be completely worthless.

What is this "composer" thing that it keeps complaining about? We never used anything like that back when we were still developing this Drupal 7 project (we abandoned PHP and switched to Python/Django a few years ago). I tried installing Drush through composer require drush/drush, which worked (and dumped a load of new code into my repo for some reason...). But even though I'm running it in the root of my repo, it says this:

! [NOTE] Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands.                  

When I pass the root folder name via --root, it says the same thing. Thus, my old strategy of just running drush up drupal, which worked dozens of times in the past, no longer works.

Could someone who understands how Drush works these days explain to me how I can use it to update my codebase? Or maybe there's a way to install an old version of Drush that can actually understand my repo's layout? That'd be even better.

  • 1
    Is this a Composer managed project? You normally Git ignore the vendor/ folder Composer creates. From where exactly and how did you call Drush? Drush has a compatibility matrix for Drupal. For D7 you need Drush 8: composer require drush/drush:^8. If this is no Composer managed project you should install Drush globally (or at least outside the Drupal root): composer global require drush/drush:^8. – leymannx Sep 17 at 6:37
1

I came across this issue myself when starting my first Drupal 8 project.

This is most likely due to the version of Drush you are using being not compatible with Drupal 7. You can check your Drush version by running drush --version in the command line.

If Drush 9 or above, you should downgrade to version 8, i.e. composer require drush/drush:^8.

Tip: if ever wondering which Drush (local or global) you are using, type which drush in the command line.

| improve this answer | |
  • 1
    Also worth to warn that it can be extremely dangerous to have a local Drush added via Composer to an unmanaged project. Running drush up then can wipe your whole project. OP should definitely try all of this on their own machine or on a backup first. – leymannx Sep 17 at 8:06
  • @leymannx Good point! But since the OP is talking about a Repo, we might assume the codebase is managed. If not, better setup Git first. – timson Sep 17 at 8:22
  • 1
    Ah yeah, I meant Composer-managed. Like with a project template. Like github.com/drupal-composer/drupal-project/tree/7.x – leymannx Sep 17 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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