Problem/Motivation

After enabling and configuring the module and creating a Content Model entity, I am not able to export it via Drush. Drush cannot find the command.

$ drush content-model-documentation:export 1

There are no commands defined in the "content-model-documentation" namespace.  

drush list does not list any of the module's commands.

I've cleared caches several times, and wiggled and tweaked anything I could to try to make it work. I've also taken a look at the code and don't see anything that stands out as incorrect/broken. So, unfortunately I don't have much to offer in the way of solutions atm. Possible Drush version issue or a change in the way Drush Commands are created that was not expected?

OTOH, I was able to do a drush generate drush:command-file for a custom module, and that command was immediately available.

Drupal version: 10.1.8
Drush version: 12.1.3.0
PHP version: 8.1.18

Steps to reproduce

1. Enable the module.
2. Go to /admin/structure/cm_document and create a new Content Model.
3. On /admin/structure/cm_document, hover over the "Edit" button for your new content model to find the id.
4. In your terminal, run drush content-model-documentation:export [your id]

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

majorrobot created an issue. See original summary.

swirt’s picture

Hi @majorrobot. Thank you for reporting this issue.

I am not seeing this on two different sites that I have up running the module.

ddev drush content-model-documentation:export 6
Exported CM Document: [6] => adminzZzstructurezZztaxonomyzZzmanagezZztagszZzdocument.yml

Can you verify two things

  1. That you are running at minimum version 1.0.21 of content_model_documentation. (that is when the export feature was added)
  2. Visit /admin/config/system/cm_document in your site and make sure you have the machine name of a local module specified. (I doubt it is this as the drush command should still be found, even though it will error.)

I doubt it is #2 as it would not prevent the drush command from existing. It would only throw back an error like this:

ddev drush content-model-documentation:export 3
Content Model Document export exception:  CM Document export to a file requires the local module path to be set and exist. Check the setting /admin/config/system/cm_document

Is it possible that your drush is running generically (outside of your site) so it is only giving you basic commands but not commands declared by your site? Your test of drush generate was a good start, but that would likely run without being connected to your site. Running "drush status" might give you info about whether it is actually acting on your site. Are there any other contrib modules in your site that also have drush commands you could test?

swirt’s picture

Actually, nevermind.. I see the problem. The command does not work with drush 12.
I will try to track down the fix and get this resolved.

swirt’s picture

Title: Drush: no commands "defined in the 'content-model-documentation' namespace" » Drush 12: no commands "defined in the 'content-model-documentation' namespace"

swirt’s picture

The current state of the PR is that it works with drush 12 but breaks with 11. :(

swirt’s picture

Fixed, tested with both drush 11 and 12. Import and export work as expected.

  • swirt committed cf5a707c on 1.0.x
    Issue #3427908 by swirt, majorrobot: Drush 12: no commands defined in...
swirt’s picture

Status: Active » Fixed
swirt’s picture