Problem

Error in generated theme

Steps to reproduce

php scripts/generate-theme.php --name='dxf2' --machine-name='dxf2' --description='DXF2 theme' --author='dmstr' --preset='flex'
PHP Notice:  Undefined variable: presets in /drupal/rocketship_theme_generator/scripts/generate-theme.php on line 369
PHP Notice:  Undefined variable: presets in /drupal/rocketship_theme_generator/scripts/generate-theme.php on line 369
PHP Notice:  Undefined variable: presets in /drupal/rocketship_theme_generator/scripts/generate-theme.php on line 369

The enabled generated theme has error after install:
Twig\Error\LoaderError type: Template "@dxf2-organisms/00-overview/_view.twig" is not defined in "themes/dxf2/components/00-theme/03-organisms/00-overview/_drupal/templates/views-view.html.twig" at line 33. Message Twig\Loader\ChainLoader->getCacheKey() function (/drupal/vendor/twig/twig/src/Loader/ChainLoader.php file in line 98).

(The site crashed.)

CommentFileSizeAuthor
#14 dxf2-demo-theme.tar_.gz3.05 MBgaborm

Comments

gaborm created an issue. See original summary.

gaborm’s picture

Issue summary: View changes
vm’s picture

Title: error in generated theme » PHP Notice: Undefined variable: presets in /drupal/rocketship_theme_generator/scripts/generate-theme.php on line 369

Better title

vm’s picture

Title: PHP Notice: Undefined variable: presets in /drupal/rocketship_theme_generator/scripts/generate-theme.php on line 369 » Errors upon install and theme generation

correct title paste.

vm’s picture

Title: Errors upon install and theme generation » Errors upon theme generation and enabling of generated theme

more descriptive.

  • rembrandx committed be8b8ea on 2.x
    Issue #3215514: Errors upon theme generation and enabling of generated...
rembrandx’s picture

@gaborm: could you check out the change I committed? This should fix your issues. One was a variable that was named incorrectly, another was I forgot to do a check for undefined:
https://www.drupal.org/commitlog/commit/104686/be8b8ea910aa1e4e496b81278...
If this fixes it, I'll add a new tag.
@VM thanks for tweaking the issue!

  • rembrandx committed 487032f on 3.x
    Issue #3215514: Errors upon theme generation and enabling of generated...
rembrandx’s picture

The weird thing is, I don't get the error on my work computer, nor during tests in Git pipelines but I do see it on my home computer. I'm thinking it has to do with the version of PHP that it's running + what kind of error logging is turned on by default.
In any case, I hope the tweak I committed fixes it for you.

rembrandx’s picture

Version: 2.0.2 » 2.0.3
Status: Active » Fixed

I got the issues that were mentioned, fixed on my home computer, so I think we're good.
Feel free to reopen if you're still having PHP errors.
Also, if you could mention what php version you are running this in, that would be helpful to further debug this.

gaborm’s picture

Same problem (but no PHP notice):

php scripts/generate-theme.php --name='dxf2' --machine-name='dxf2' --description='DXF2 theme' --author='dmstr' --preset='flex'

After enable theme (dxf2) the site crash. In dblog:

Twig\Error\LoaderError type: Template "@dxf2-molecules/user/_user--content.twig" is not defined in "themes/dxf2/components/00-theme/02-molecules/user/_drupal/templates/user.html.twig" at line 20. Message Twig\Loader\ChainLoader->getCacheKey() function (/drupal/vendor/twig/twig/src/Loader/ChainLoader.php file in line 98.).

PHP: php-7.4.19-1.fc34.x86_64
rocketship_theme_generator: 2.0.4 released 25 May 2021

rembrandx’s picture

Okay, so there's 2 separate issues:
- PHP errors
-Some (or possibly a lot of) twig templates not being found

The first issue is fixed in 2.0.3.
The other one is something I can't reproduce, so it's most likely one of these 2 things:

1)
You're using components 3.x, which is currently untested in the current Rocketship distributions (uses 2.x). The way the aliases are constructed in dxf2.info is not compatible. It's easily fixed by rewriting it like this:

components:
  namespaces:
    dxf2-base:
      - components/00-theme/00-base
    dxf2-atoms:
      - components/00-theme/01-atoms
    dxf2-molecules:
      - components/00-theme/02-molecules
    dxf2-organisms:
      - components/00-theme/03-organisms
    dxf2-p-organisms:
      - components/01-paragraphs/03-organisms
    dxf2-templates:
      - components/00-theme/04-templates
    dxf2-pages:
      - components/00-theme/05-pages
    dxf2-demo:
      - components/00-theme/06-demo
    dxf2-news-molecules:
      - components/02-features/f001-news/02-molecules
    dxf2-blog-molecules:
      - components/02-features/f002-blog/02-molecules
    dxf2-office-atoms:
      - components/02-features/f006-office/01-atoms
    dxf2-office-molecules:
      - components/02-features/f006-office/02-molecules
    dxf2-realisation-molecules:
      - components/02-features/f007-realisation/02-molecules
    dxf2-service-molecules:
      - components/02-features/f008-service/02-molecules
    dxf2-product-molecules:
      - components/02-features/f009-product/02-molecules
    dxf2-job-molecules:
      - components/02-features/f012-job/02-molecules
    dxf2-event-molecules:
      - components/02-features/f014-event/02-molecules

2) Or the templates mentioned, were not copied by the generator. I tested in php 5.6, 7.3 and 7.4 and it copies + the theme works on my end. If the templates don't copy for you, it's a mystery to me. As a quick-fix, you could try manually copying the missing templates from the 'templates/BASE'-folder in the generator and replacing mentions of %theme_prefix% with your theme's machine name: dxf2

rembrandx’s picture

Status: Fixed » Needs work
gaborm’s picture

StatusFileSize
new3.05 MB

I uploaded the (original) generated demo theme. Can You examine it?

rembrandx’s picture

It has the correct twig-templates for the user pages and everything renders just fine in my test project.
The problem is mostly likely that you are missing a dependency.

As I mentioned, you need the correct version of this components module to be enabled. 8.x-2.4 (the latest green one) should be compatible with the theme.
Also make sure you have this Unified Twig Extensions module installed and enabled.

Both of these modules are normally installed by the Rocketship Core module (part of the the Rocketship distribution). So if you don't have those 2 modules enabled, the root cause might be something failed during the Rocketship installation or something that was changed to your project's composer file and you'll probably have more issues then just the theme not loading. If that is the case, you're better off making an issue in the Rocketship distribution project.

gaborm’s picture

Thanks! It works! :)
(components + unified_twig_ext modules)

rembrandx’s picture

Version: 2.0.3 » 2.0.4
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.