drush icon indicating copy to clipboard operation
drush copied to clipboard

drush up drupal Unable to load class \Drush\VersionControl\Backup | Drupal7

Open jlariza opened this issue 3 years ago • 18 comments

Describe the bug using drush 8.4.8 for Drupal 7.78 When running drush up drupal on a localmachine, It raises

Unable to load class \Drush\VersionControl\Backup

and do not allow to update core

System Configuration

Drupal version                  :  7.78
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  127.0.0.1
 Database port                   :  52000
 Database username               :  user
 Database name                   :  test
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :
 Default theme                   :  custom-theme
 Administration theme            :  seven
 PHP configuration               :  /usr/local/etc/php/7.4/php.ini
 PHP OS                          :  Darwin
 Drush script                    :  /usr/local/bin/drush
 Drush version                   :  8.4.8
 Drush temp directory            :  /tmp
 Drush configuration             :
 Drush alias files               :  /path/to/drupal-site/docroot
                                    /sites/all/drush/aliases.drushrc.php
 Install profile                 :  standard
 Drupal root                     :  /path/to/drupal-site/docroot
 Drupal Settings File            :  sites/default/settings.php
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Private file directory path     :  sites/default/files/private
 Temporary file directory path   :  /tmp

jlariza avatar Apr 20 '21 16:04 jlariza

If you run with --no-backup does it work, or do you just get a different error?

greg-1-anderson avatar Apr 20 '21 16:04 greg-1-anderson

@greg-1-anderson running it with that flag raise the same error

Unable to load class \Drush\VersionControl\Backup

jlariza avatar Apr 20 '21 16:04 jlariza

Just wondering if there has been any addition resolution to this issue. I am on Drupal 7.91 with Drush 8.4.11 and receiving the same error: Unable to load class \Drush\VersionControl\Backup

pelowe avatar Nov 01 '22 19:11 pelowe

composer remove drush/drush and then composer global require drush/drush:8.x

Find where drush is installed then by running composer global show drush/drush

f1rf1n avatar Dec 11 '22 00:12 f1rf1n

composer global require is deprecated; see Fixing the Composer Global Command.

Does this bug only happen on site-local installs of Drush 8?

greg-1-anderson avatar Dec 11 '22 16:12 greg-1-anderson

I have the same error too!

Drush 8.4.11 / Drupal 7.91 on PHP 7.4.

The debug say :

Verifying signature for svn version control engine. [6.51 sec, 30.89 Mo]                                                                                                     [debug]
Executing: svn info /var/www/fedae-d7/drupal-7.93
  sh: 1: svn: not found
Verifying signature for bzr version control engine. [6.52 sec, 30.89 Mo]                                                                                                     [debug]
Executing: bzr root /var/www/fedae-d7/drupal-7.93
  sh: 1: bzr: not found
Unable to load class \Drush\VersionControl\Backup [6.52 sec, 30.89 Mo]                                                                                                   [error]
Returned from hook drush_pm_updatecode [6.52 sec, 18.23 Mo]                                                                                                                  [debug]

When I install bzr, it say :

Verifying signature for svn version control engine. [23.93 sec, 30.9 Mo]                                                                                                     [debug]
Executing: svn info /var/www/fedae-d7/drupal-7.93
  svn: E155007: '/var/www/fedae-d7/drupal-7.93' is not a working copy
Verifying signature for bzr version control engine. [23.94 sec, 30.89 Mo]                                                                                                    [debug]
Executing: bzr root /var/www/fedae-d7/drupal-7.93
  brz: ERROR: Not a branch: "/var/www/fedae-d7/drupal-7.93/".
Unable to load class \Drush\VersionControl\Backup [24.05 sec, 30.9 Mo]                                                                                                   [error]
Returned from hook drush_pm_updatecode [24.05 sec, 18.23 Mo]                                                                                                                 [debug]

I use Drush in local (with Drush launcher) because we have a D9 in other folder and we need to have 2 versions of drush in the same server.

Bessonweb avatar Dec 12 '22 10:12 Bessonweb

@greg-1-anderson For me it fails with the project-locally installed drush. But works with global installed drush.

Also I can not install cgr -> Found this https://github.com/consolidation/cgr/issues/40

~~ doesn't work with php8 apparently? See error quoted below.~~ ~~ > webmaster@shell:~$ composer global require consolidation/cgr

Info from https://repo.packagist.org: #StandWithUkraine Cannot use consolidation/cgr's latest version 2.0.5 as it requires php ^5.3.2 || ^7.0 which is not satisfied by your platform.

Installation failed, deleting ./composer.json.

In RequireCommand.php line 218: No composer.json present in the current directory (./composer.json), this may be the cause of the following exception.

In PackageDiscoveryTrait.php line 313:
Package consolidation/cgr has requirements incompatible with your PHP version, PHP extensions and Composer version:
- consolidation/cgr 2.0.5 requires php ^5.3.2 || ^7.0 which does not match your installed version 8.0.25. ~~

f1rf1n avatar Dec 12 '22 19:12 f1rf1n

My server manager say it's possible that Drupal was installed or updated manually and it's possibly the reason of this bug.

I will try to uninstall Drupal manually and reinstall it with Drush to verify if it's a possible resolution to that situation.

Bessonweb avatar Dec 13 '22 09:12 Bessonweb

Yeah, cgr needs some love; you don't need to use it directly, but you should install each component (e.g. Drush) in a separate folder, e.g. via composer require.

If anyone has any ideas as to why that class cannot be found, please let me know.

greg-1-anderson avatar Dec 13 '22 16:12 greg-1-anderson

We were having the same issue and fixed upgrading the Drush version to 8.4.12. Hope this helps.

bdalomgir avatar Mar 23 '23 07:03 bdalomgir

@bdalomgir: Using Drupal 8.4.12 with Drupal 7, still same problem.

nerdoc avatar Apr 21 '23 20:04 nerdoc

@nerdoc Mostly it's a Drush versioning problem so please try another Drush version, it might be a workaround.

bdalomgir avatar Apr 26 '23 05:04 bdalomgir

@bdalomgir but Drush 9 isn't compatible with D7 (which I am stuck with...)

nerdoc avatar Apr 30 '23 06:04 nerdoc

For me it fails with the project-locally installed drush. But works with global installed drush.

Somehow I missed this comment in the past, or failed to note its significance. Is everyone on this thread having problems with using the pm commands with a project-local Drush? That is not a supported configuration; if you have a project-local Drush, then you are supposed to use Composer to manage your site, not Drush pm.

What is the use case for using Drush pm with a site-local Drush? Could you switch to a global Drush if you want to use the pm commands? I would consider an enhancement to pm to allow for site-local Drush, but I don't have the bandwidth to implement it myself.

Also, if anyone wants to try to isolate the problem, it might be useful to know if older versions of Drush 8 work correctly in this configuration -- presuming that your environment allows you to use the older versions.

greg-1-anderson avatar Apr 30 '23 13:04 greg-1-anderson

I am using Drush via composer, not locally, and having the problem.

nerdoc avatar May 09 '23 06:05 nerdoc

I have tested many versions of Drush and the problem stay the same.

I'm obliged to work with a local version of Drush because I have other websites in Drupal 9 in the same server.

For the moment I'm obliged to update Drupal 7 manually and it's not pratical... :-(

Thanks for your work!

Bessonweb avatar May 09 '23 09:05 Bessonweb

@nerdoc For my case I can see in the d7 document root drush version did not work perfectly, so I had to run the up command from outside the d7 document root. my document root was /var/www/projectName/src and I run the drush command from /var/www/projectName Command drush up drupal --root=src and my drush version was 8.4.12 Please try this way hope it will help you.

bdalomgir avatar May 09 '23 10:05 bdalomgir

If you have other Durpal sites that are Drupal 9 or 10, then you may use a site-local Drush for those versions, and use a global install of Drush 8 with your Drupal 7 sites. If you want to use a site-local Drush with Drupal 7, you could also make your Drupal 7 site Composer-managed; then you wouldn't need to use pm:update.

greg-1-anderson avatar May 09 '23 12:05 greg-1-anderson