While installing drupal via drupal-console i receive the following error:
``` PHP Fatal error: Class 'Drupal\bootstrap\Bootstrap' not found in themes/contrib/bootstrap/bootstrap.theme on line 30```

I created a custom installation profile to installs and enables my bootstrap subtheme.
Installing via browser or drush works fine.

I'm not sure if this is an error related to drupal-console or your theme.

Comments

michaelpetri created an issue. See original summary.

markhalliwell’s picture

Status: Active » Closed (works as designed)

It's related to drupal-console as I have never seen this error creating a sub-theme manually.

kevinwal’s picture

Status: Closed (works as designed) » Active

Same issue on Acquia Site Factory since you need to have it be a profile to load into the system. Will post as we diagnose.

markhalliwell’s picture

Category: Bug report » Support request
Status: Active » Closed (works as designed)

This isn't an issue with this project at all. Core, by default now in 8.x, allows any project to autoload namespaced project classes. If it's not working, it's due to whatever environment is handling the autoclass loading.

pfrenssen’s picture

Usually you can solve it by regenerating the composer autoload files:

$ composer dump-autoload
elex’s picture

The problem is that the install script calls this function _drupal_maintenance_theme which sets the default theme to bootstrap. You can workaround this by adding this to settings.php

$settings['maintenance_theme'] = 'seven';
heshanlk’s picture

For some reason when I use the Devel module and the `Rebuild the theme registry on every page load` is on the issue appeared to pop. Try disabling the settings and it worked for me.

rlhawk’s picture

I can confirm that this error results from enabling "Rebuild the theme registry on every page load" in Devel.

betarobot’s picture

It also comes with enabling "Rebuild the theme registry on every page load" in Devel for me. This option worked totally fine in D7, so something is clearly wrong. But can't figure out yet is it Bootstrap issue or something else.

ridefree’s picture

Ditto for enabling "Rebuild the theme registry on every page load". My subtheme was working for a few months on a fairly plain d8 install. Enabling this in the Dev module gave me the same errors (but not for other themes).

aken.niels@gmail.com’s picture

Workaround in #6 works for me, using `drupal site:install`.

jaydee1818’s picture

I can confirm that the combination of Bootstrap theme + Devel module with "Rebuild the theme registry on every page load" checked produces this error

chamilsanjeewa’s picture

@heshanlk yes its works. But I need to keep "Rebuild the theme registry on every page load" setting on for my development site. is there any solution to enable this setting with bootsrap subtheme.

heshanlk’s picture

Version: 8.x-3.0-beta2 » 8.x-3.x-dev
Status: Closed (works as designed) » Active

@chamilsanjeewa you can try the suggested solutions until contributors have some solution for this.

markhalliwell’s picture

Status: Active » Closed (works as designed)

As I said above, this is not an issue with this project specifically.

chamilsanjeewa’s picture

Don't need to turn on "Rebuild the theme registry on every page load", Here I found another alternative to for rebuild template cache in every page reload.

https://www.drupal.org/node/2598914

sharif.elshobkshy’s picture

Hey guys.

I'm getting the same error message when trying to install a Drupal 8 site with drupalconsole.

The site I'm trying to install has a custom profile that sets the bootstrap subtheme as default theme (using the config files).
I don't have the devel module enabled, so it's not a cache settings related issue.

Error: Class 'Drupal\bootstrap\Bootstrap' not found in xxxx\profiles\inmo\themes\bootstrap\bootstrap.theme on line 30 #0 xxxx\core\lib\Drupal\Core\Extension\Extension.php(140): include_once()

When I install the site using the Drupal interface (and choosing my profile) the Bootstrap subtheme is enabled without any problem.

It seem to be an issue with drupalconsole and how the site:install command works.

Sharif.

yukare’s picture

aken.niels@gmail.com’s picture

FWIW, we also have a profile which enabled Bootstrap on install and made drupal site:install break. We've disable this functionality, it's a lot quicker for us to manually enable Bootstrap then bumping into this issue time and time again.

Also, might be good to note, that #6 worked for us as well, though not a really solid workaround for us.

mikran’s picture

Hey! I might have just discovered something. We had this issue on one project and the other one using same theme did not have this issue. After comparing drush cim outputs after initial site install I discovered that the failing site also uninstalled one theme whilst the working one didn't.

The theme that was getting uninstalled was stark ([notice] Synchronized extensions: uninstall stark.). I enabled stark theme to my configuration and now the process works, the error is gone.

Can any of you who had this problem and if you built workarounds around it try this and see it it works?

markhalliwell’s picture

alexverb’s picture

I tried the mentioned "workarounds" in this thread. The only one that seemed to work is to disable the theme and use a core theme to perform an --existing-config installation. My best guess is that sub themes do not get the classes of its parent theme loaded. Definitely a core issue.

mglaman’s picture

I really wish we could at least do this:

/**
 * Initialize the active theme.
 */
if (class_exists('\Drupal\bootstrap\Bootstrap')) {
  Bootstrap::initialize(); 
}

This causes grief when trying to use the quick-start command when the profile uses Bootstrap.

markhalliwell’s picture

If it did that, then it would mask the error instead of doing its job: telling you something is wrong. As stated above, this is an issue with core itself.