drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.34k stars 1.08k forks source link

drush cr adds DrushLog to runtime cache_container resulting in runtime crash #6031

Closed sukr closed 4 months ago

sukr commented 4 months ago

Describe the bug After doing drush cr on 11.x version and launching the site results in crash `The website encountered an unexpected error. Try again later.

Error: Class "Drush\Log\DrushLog" not found in Drupal\Component\DependencyInjection\Container->createService() (line 259 of core/lib/Drupal/Component/DependencyInjection/Container.php). Drupal\Component\DependencyInjection\Container->get() (Line: 430) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 273) Drupal\Component\DependencyInjection\Container->createService() (Line: 177) Drupal\Component\DependencyInjection\Container->get() (Line: 430) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 249) Drupal\Component\DependencyInjection\Container->createService() (Line: 177) Drupal\Component\DependencyInjection\Container->get() (Line: 430) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 237) Drupal\Component\DependencyInjection\Container->createService() (Line: 177) Drupal\Component\DependencyInjection\Container->get() (Line: 430) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 273) Drupal\Component\DependencyInjection\Container->createService() (Line: 177) Drupal\Component\DependencyInjection\Container->get() (Line: 430) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 237) Drupal\Component\DependencyInjection\Container->createService() (Line: 177) Drupal\Component\DependencyInjection\Container->get() (Line: 197) Drupal::service() (Line: 31) twig_render_template() (Line: 348) ....`

To Reproduce Setup Drupal 11.x Clear cache with drush cr

Expected behavior Cache is rebuilt with out Drush components and site works.

Actual behavior DrushLog component is added to cache, runtime crashes.

Workaround Don't use drush cr

System Configuration

Q A
Drush version? 12.5.2.0
Drupal version? 11.x
PHP version 8.x
OS? Mac - ddev / Linux

Additional information

gitressa commented 4 months ago

I can't reproduce the error, drush cache:rebuild works well ...

DDEV in Debian 12

$ ddev version
 ITEM             VALUE
 DDEV version     v1.23.1
 architecture     amd64
 cgo_enabled      0
 db               ddev/ddev-dbserver-mariadb-10.11:v1.23.1
 ddev-ssh-agent   ddev/ddev-ssh-agent:v1.23.1
 docker           26.1.4
 docker-api       1.45
 docker-compose   v2.27.0
 docker-platform  linux-docker
 mutagen          0.17.2
 os               linux
 router           ddev/ddev-traefik-router:v1.23.1
 web              ddev/ddev-webserver:v1.23.1
$ ddev describe
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: drupal11 ~/dev/drupal11 https://drupal11.ddev.site                            │
│ Docker platform: linux-docker                                                          │
│ Router: traefik                                                                        │
├──────────┬──────┬─────────────────────────────────────────────────┬────────────────────┤
│ SERVICE  │ STAT │ URL/PORT                                        │ INFO               │
├──────────┼──────┼─────────────────────────────────────────────────┼────────────────────┤
│ web      │ OK   │ https://drupal11.ddev.site                      │ drupal PHP8.3      │
│          │      │ InDocker: web:443,80,8025                       │ nginx-fpm          │
│          │      │ Host: 127.0.0.1:32805,32807                     │ docroot:'web'      │
│          │      │                                                 │ Perf mode: none    │
│          │      │                                                 │ NodeJS:20          │
├──────────┼──────┼─────────────────────────────────────────────────┼────────────────────┤
│ db       │ OK   │ InDocker: db:3306                               │ mariadb:10.11      │
│          │      │ Host: 127.0.0.1:32808                           │ User/Pass: 'db/db' │
│          │      │                                                 │ or 'root/root'     │
├──────────┼──────┼─────────────────────────────────────────────────┼────────────────────┤
│ Mailpit  │      │ Mailpit: https://drupal11.ddev.site:8026        │                    │
│          │      │ `ddev mailpit`                                  │                    │
├──────────┼──────┼─────────────────────────────────────────────────┼────────────────────┤
│ All URLs │      │ https://drupal11.ddev.site,                     │                    │
│          │      │ https://127.0.0.1:32805,                        │                    │
│          │      │ http://drupal11.ddev.site,                      │                    │
│          │      │ http://127.0.0.1:32807                          │                    │
└──────────┴──────┴─────────────────────────────────────────────────┴────────────────────┘

Drupal

$ drush st
Drupal version   : 11.0.0-beta1
Site URI         : https://drupal11.ddev.site
DB driver        : mysql
DB hostname      : db
DB port          : 3306
DB username      : db
DB name          : db
Database         : Connected
Drupal bootstrap : Successful
Default theme    : olivero
Admin theme      : claro
PHP binary       : /usr/bin/php8.3
PHP config       : /etc/php/8.3/cli/php.ini
PHP OS           : Linux
PHP version      : 8.3.7
Drush script     : /var/www/html/vendor/bin/drush
Drush version    : 13.0.0.0-beta3
Drush temp       : /tmp
Drush configs    : /var/www/html/vendor/drush/drush/drush.yml
Install profile  : standard
Drupal root      : /var/www/html/web
Site path        : sites/default
Files, Public    : sites/default/files
Files, Temp      : /tmp

Installed like this in DDEV:

$ mkdir drupal11 && cd drupal11
$ ddev config --project-type=drupal --docroot=web --php-version=8.3
$ ddev start
$ ddev composer create drupal/recommended-project:^11@alpha
# See https://github.com/drush-ops/drush/issues/6032 for details
$ ddev composer require drush/drush chi-teck/drupal-code-generator:4.x-dev
sukr commented 4 months ago

Thanks for the quick response, what information can I share as I can consistently reproduce it.

Once the error occurs, I run update.php and site starts to work fine. Then on the next drush cr it fails with the above error.

Not sure if this helps, when I run FunctionalJavascript phpunit tests for d11, they all fail with the same error

gitressa commented 4 months ago

You're welcome! It would be a help if you added more details about your setup, like which commands did you use to build your installation, and perhaps also your composer.json file, and other relevant information.

sukr commented 4 months ago

composer.json

If you could give me any hints on where to start looking, I could also debug and help in finding a resolution

weitzman commented 4 months ago

You need to use Drush 13 with Drupal 11

greg-1-anderson commented 4 months ago

Sounds like OP is maybe using a global install of Drush, instead of adding it to the site via Composer?

sukr commented 4 months ago

The problem has resolved by itself. Not sure though how it happened. thanks for ask the support.