"$container is not initialized yet" errors following upgrade to D11.1.0

Created on 8 January 2025, 4 months ago

Problem/Motivation

After upgrading my site from Drupal core 11.0.9 to 11.1.0, I got fatal errors when attempting to run drush commands.

\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.

I also could not visit site in a brower (WSOD).

Steps to reproduce

  1. Upgrade Drupal site to 11.0.9
  2. Require and install this module, version 1.1.11
  3. Upgrade Drupal site to either core 11.1.0 or 11.1.1
  4. Attempt drush cr or drush updb
  5. Error encountered

Proposed resolution

Change the syntax of the includes in the module file from:

include \Drupal::service('extension.list.module')->getPath('launch_checklist') . '/inc/routes.inc';

to

require_once __DIR__ . '/inc/routes.inc';

Remaining tasks

I'm submitting a patch that does this momentarily.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States banoodle San Francisco, CA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024