Creating a sub-theme for a theme that has declared a "dependency" results in "theme was not found"

Created on 15 August 2019, over 5 years ago
Updated 27 March 2024, 9 months ago

For the last two days I have been trying to discover the reason for a strange bug in a custom theme that I am currently developing.

Basically, I created a subtheme of a subtheme that simply wouldn't allow me to "install" it: I always got the "theme was not found" error message, although the theme appeared to be there and all required files were present. (Similar to what is described here , but not restricted to Install and set default, but also appearing on hitting Install.)

I found out how to circumvent this bug only by investigating the code in ThemeInstaller.php: Turns out the reason for this was a dependency that I had set on the parent theme (using the feature introduced here ): When I removed this dependency, the subtheme could be installed without problems.

Steps for reproducing the bug:

  • Create a simple theme parent (can be a subtheme of another theme) and declare a dependency on some module in parent.info.yml.
  • Create a simple subtheme child of theme parent with only a basic setup in child.info.yml.
  • Click Install on the /admin/appearancepage.

This results in an error message: "The child theme was not found." I haven't done a through investigation, but I think, this is caused at this point in ThemeInstaller.php:

        foreach (array_keys($theme_data[$theme]->requires) as $dependency) {
          if (!isset($theme_data[$dependency])) {
            // The dependency does not exist.
            return FALSE;
          }

          // Skip already installed themes.
          if (!isset($theme_list[$dependency]) && !isset($installed_themes[$dependency])) {
            $theme_list[$dependency] = $dependency;
          }
        }
🐛 Bug report
Status

Closed: cannot reproduce

Version

11.0 🔥

Component
Theme 

Last updated 9 minutes ago

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia pameeela

    I can't reproduce this with the steps provided, so I think it must have been fixed in the meantime. Here is what I did:

    1. Created a custom module
    2. Created a parent theme that had a custom base theme and had the custom module as a dependency
    3. Created a child theme that used parent as base theme

    First, I get a message that I have to enable my custom module in order to install the themes (this is already different behaviour from the OP):

    After enabling the module I am able to install either of the themes:

    The child theme installs correctly:

    So I'm marking this as closed but if anyone else can provide updated steps to reproduce the issue, please re-open.

Production build 0.71.5 2024