Skip to content

fix(drupal-contrib): rebuild caches before enabling the module, fixes #153 - #226

Merged
rfay merged 1 commit into
mainfrom
20261104_stasadev_contrib_drush_cr
Nov 4, 2026
Merged

rfay merged 1 commit into
mainfrom
20261104_stasadev_contrib_drush_cr

Conversation

@stasadev

@stasadev stasadev commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

Contrib setup now runs drush cr between drush si and drush en, which stops the intermittent "no commands defined in the pm namespace" failures.

The Issue

The daily contrib CI jobs often fail on the first attempt and pass on rerun. Example: https://github.com/ddev/coder-ddev/actions/runs/41777312122/job/126400559017

✓ Drupal installed (6s)
Enabling pathauto (module)...

  There are no commands defined in the "pm" namespace.

Failed to run drush en pathauto -y: exit status 1
✗ pathauto not found in enabled modules — enable failed

The ddev-web healthcheck requests the site every 10s. If a request lands during drush si, Drupal caches a container from a half-installed site. The next drush en boots from it, and Drush fails to autowire PmCommands:

[debug] Could not instantiate Drush\Commands\pm\PmCommands: Cannot autowire service "Drupal\user\PermissionHandlerInterface"

Drush logs this only with --debug. The same stale cache can also fail with Call to undefined function Drupal\update\Hook\update_storage_clear().

Drupal 11 is affected most. Its installer installs system alone before user and the other profile modules, which leaves a window. Drupal 12 installs them together (#3614153), so the same loop failed 1/22 times instead of 21/21.

How This PR Solves The Issue

drush cr after drush si rebuilds the container from the installed site. drupal-core already does this. test-issue-branches.sh gets the same fix.

Manual Testing Instructions

In a pathauto checkout with ddev-drupal-contrib, request the site in a loop:

while true; do curl -s -o /dev/null "$(ddev describe -j | jq -r .raw.httpurl)"; sleep 1; done &
ddev drush si minimal -y && ddev drush en pathauto -y
# Expect: fails most of the time
ddev drush si minimal -y && ddev drush cr && ddev drush en pathauto -y
# Expect: succeeds
kill %1

Automated Testing Overview

Claude Code ran the loop above locally (Drush 13.8, Drupal 11.4): without drush cr, 15/15 runs failed; with it, 15/15 passed. CI contrib jobs confirm the template change.

🤖 Developed with assistance from Claude Code

…153

## Short Summary (TL;DR)

Contrib setup now runs `drush cr` between `drush si` and `drush en`, which stops the intermittent "no commands defined in the pm namespace" failures.

## The Issue

- Fixes #153

The daily contrib CI jobs often fail on the first attempt and pass on rerun. Example: https://github.com/ddev/coder-ddev/actions/runs/41777312122/job/126400559017

```
✓ Drupal installed (6s)
Enabling pathauto (module)...

  There are no commands defined in the "pm" namespace.

Failed to run drush en pathauto -y: exit status 1
✗ pathauto not found in enabled modules — enable failed
```

The `ddev-web` healthcheck requests the site every 10s. If a request lands during `drush si`, Drupal caches a container from a half-installed site. The next `drush en` boots from it, and Drush fails to autowire `PmCommands`:

```
[debug] Could not instantiate Drush\Commands\pm\PmCommands: Cannot autowire service "Drupal\user\PermissionHandlerInterface"
```

Drush logs this only with `--debug`. The same stale cache can also fail with `Call to undefined function Drupal\update\Hook\update_storage_clear()`.

## How This PR Solves The Issue

`drush cr` after `drush si` rebuilds the container from the installed site. `drupal-core` already does this. `test-issue-branches.sh` gets the same fix.

## Manual Testing Instructions

In a pathauto checkout with `ddev-drupal-contrib`, request the site in a loop:

```bash
while true; do curl -s -o /dev/null "$(ddev describe -j | jq -r .raw.httpurl)"; sleep 1; done &
ddev drush si minimal -y && ddev drush en pathauto -y
# Expect: fails most of the time
ddev drush si minimal -y && ddev drush cr && ddev drush en pathauto -y
# Expect: succeeds
kill %1
```

## Automated Testing Overview

Claude Code ran the loop above locally (Drush 13.8, Drupal 11.4): without `drush cr`, 15/15 runs failed; with it, 15/15 passed. CI contrib jobs confirm the template change.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-04 20:20 UTC

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rfay
rfay merged commit f3b5c72 into main Nov 4, 2026
16 checks passed
@rfay
rfay deleted the 20261104_stasadev_contrib_drush_cr branch November 4, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intermittent: drush en fails with 'no commands defined in the pm namespace' in contrib CI

2 participants