subtheme generation via generate-theme broken

Created on 30 January 2025, 3 months ago

Problem/Motivation

When trying to generate a subtheme using bootstrap5 v4.0.3 as a starterkit an error is (now) returned.

Steps to reproduce

1. composer create-project drupal/recommended-project:^11
2. composer require 'drupal/bootstrap5:^4.0'
3. php web/core/scripts/drupal generate-theme my_theme --starterkit=bootstrap5
[ERROR] Theme source theme bootstrap5 is not a valid starter kit.

Proposed resolution

Add (new) bootstrap5.starterkit.yml and move/transform "starterkit: true" from bootstrap5.info.yml to it.
Attached example file, able to generate subtheme with it in place.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States etxaleku

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

Comments & Activities

  • Issue created by @etxaleku
  • πŸ‡ΊπŸ‡ΈUnited States etxaleku

    This Drupal page documents the starterkit change - β†’

  • πŸ‡ΊπŸ‡ΈUnited States etxaleku

    Hmm, it looks like there are multiple automated ways to generate a subtheme.

    Option 1 -

    php web/core/scripts/drupal generate-theme my_theme --starterkit=bootstrap5

    Option 2 -

    drush --include="web/themes/contrib/bootstrap5/src/Drush" bootstrap5:generate-subtheme my_theme --subtheme-name="My Theme"

    Option 1 works in Drupal 11.1.2 (after manually creating bootstrap5.starterkit.yml) while Option 2 fails with this stacktrace -

    Error: Class "Drupal\bootstrap5\SubthemeManager" not found in /var/www/html/web/themes/contrib/bootstrap5/src/Drush/Commands/Bootstrap5Commands.php on line 67 #0 [internal function]: Drush\Commands\Bootstrap5Commands->generateSubtheme()
    #1 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
    #2 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
    #3 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
    #4 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(387): Consolidation\AnnotatedCommand\CommandProcessor->process()
    #5 /var/www/html/vendor/symfony/console/Command/Command.php(279): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
    #6 /var/www/html/vendor/symfony/console/Application.php(1094): Symfony\Component\Console\Command\Command->run()
    #7 /var/www/html/vendor/symfony/console/Application.php(342): Symfony\Component\Console\Application->doRunCommand()
    #8 /var/www/html/vendor/symfony/console/Application.php(193): Symfony\Component\Console\Application->doRun()
    #9 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
    #10 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
    #11 /var/www/html/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
    #12 /var/www/html/vendor/bin/drush.php(119): include('...')
    #13 {main}
    Error: Class "Drupal\bootstrap5\SubthemeManager" not found in Drush\Commands\Bootstrap5Commands->generateSubtheme() (line 67 of /var/www/html/web/themes/contrib/bootstrap5/src/Drush/Commands/Bootstrap5Commands.php).
     [warning] Drush command terminated abnormally.
    
  • πŸ‡¬πŸ‡§United Kingdom rossb89 Bristol

    The README.md has the wrong command name in I think.

    The readme states this:
    drush --include="web/themes/contrib/bootstrap5/src/Drush" bootstrap5:subtheme MACHINE_NAME --subtheme-name="SUBTHEME_NAME"

    When it should be this:

    drush --include="web/themes/contrib/bootstrap5/src/Drush" bootstrap5:generate-subtheme MACHINE_NAME --subtheme-name="SUBTHEME_NAME"

    And make sure the base theme is enabled to start with or you'll get this error:

    Error: Class "Drupal\bootstrap5\SubthemeManager" not found in Drush\Commands\Bootstrap5Commands->generateSubtheme()
    

    After enabling the theme and running the correct Drush command, it does work and generate the sub theme.

Production build 0.71.5 2024