diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc
index b98d28a..454f840 100644
--- a/core/includes/theme.maintenance.inc
+++ b/core/includes/theme.maintenance.inc
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Component\Utility\Unicode;
+use Drupal\Core\Theme\MissingThemeDependencyException;
 use Drupal\Core\Site\Settings;
 
 /**
@@ -31,37 +32,7 @@ function _drupal_maintenance_theme() {
   require_once __DIR__ . '/database.inc';
   Unicode::check();
 
-  // Install and update pages are treated differently to prevent theming overrides.
-  if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
-    if (drupal_installation_attempted()) {
-      $custom_theme = $GLOBALS['install_state']['theme'];
-    }
-    else {
-      $custom_theme = Settings::get('maintenance_theme', 'seven');
-    }
-  }
-  else {
-    // Use the maintenance theme if specified, otherwise attempt to use the
-    // default site theme.
-    try {
-      $custom_theme = Settings::get('maintenance_theme', '');
-      if (!$custom_theme) {
-        $config = \Drupal::config('system.theme');
-        $custom_theme = $config->get('default');
-      }
-    }
-    catch (\Exception $e) {
-      // Whatever went wrong (often a database connection problem), we are
-      // about to fall back to a sensible theme so there is no need for special
-      // handling.
-    }
-    if (!$custom_theme) {
-      // We have been unable to identify the configured theme, so fall back to
-      // a safe default. Bartik is reasonably user friendly and fairly generic.
-      $custom_theme = 'bartik';
-    }
-  }
-
+  $custom_theme = _drupal_get_maintenance_theme();
   $themes = \Drupal::service('theme_handler')->listInfo();
 
   // If no themes are installed yet, or if the requested custom theme is not
@@ -134,3 +105,45 @@ function template_preprocess_authorize_report(&$variables) {
   }
   $variables['messages'] = $messages;
 }
+
+/**
+ * Gets the theme used for maintenance page.
+ *
+ * @return string
+ *   The name of the maintenance page theme.
+ */
+function _drupal_get_maintenance_theme() {
+  // Install and update pages are treated differently to prevent theming
+  // overrides.
+  if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
+    if (drupal_installation_attempted()) {
+      $custom_theme = $GLOBALS['install_state']['theme'];
+    }
+    else {
+      $custom_theme = Settings::get('maintenance_theme', 'seven');
+    }
+  }
+  else {
+    // Use the maintenance theme if specified, otherwise attempt to use the
+    // default site theme.
+    try {
+      $custom_theme = Settings::get('maintenance_theme', '');
+      if (!$custom_theme) {
+        $config = \Drupal::config('system.theme');
+        $custom_theme = $config->get('default');
+      }
+    }
+    catch (\Exception $e) {
+      // Whatever went wrong (often a database connection problem), we are
+      // about to fall back to a sensible theme so there is no need for special
+      // handling.
+    }
+    if (!$custom_theme) {
+      // We have been unable to identify the configured theme, so fall back to
+      // a safe default. Bartik is reasonably user friendly and fairly generic.
+      $custom_theme = 'bartik';
+    }
+  }
+
+  return $custom_theme;
+}
diff --git a/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php
new file mode 100644
index 0000000..eb497e2
--- /dev/null
+++ b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Theme\MissingThemeDependencyException.
+ */
+
+namespace Drupal\Core\Theme;
+
+/**
+ * Exception to be thrown when base theme for installed theme is not installed.
+ *
+ * @see \Drupal\Core\Theme\ThemeInitialization::getActiveThemeByName().
+ */
+class MissingThemeDependencyException extends \Exception {
+
+  /**
+   * The missing theme dependency.
+   *
+   * @var string
+   */
+  public $theme;
+
+  /**
+   * Constructs the exception.
+   *
+   * @param string $message
+   *   The exception message.
+   * @param string $theme
+   *   The missing theme dependency.
+   */
+  public function __construct($message, $theme) {
+    parent::__construct($message);
+    $this->theme = $theme;
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
index 95f27a9..af4b2c6 100644
--- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php
+++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
@@ -109,6 +109,9 @@ public function getActiveThemeByName($theme_name) {
     $ancestor = $theme_name;
     while ($ancestor && isset($themes[$ancestor]->base_theme)) {
       $ancestor = $themes[$ancestor]->base_theme;
+      if (!$this->themeHandler->themeExists($ancestor)) {
+        throw new MissingThemeDependencyException(sprintf('Base theme %s has not been installed.', $ancestor), $ancestor);
+      }
       $base_themes[] = $themes[$ancestor];
     }
 
diff --git a/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php b/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php
index f2b1547..cd5c1be 100644
--- a/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php
+++ b/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php
@@ -34,6 +34,9 @@ public function initTheme($theme_name);
    *
    * @return \Drupal\Core\Theme\ActiveTheme
    *   An active theme object instance for the given theme.
+   *
+   * @throws \Drupal\Core\Theme\MissingThemeDependencyException
+   *   Thrown when base theme for installed theme is not installed.
    */
   public function getActiveThemeByName($theme_name);
 
diff --git a/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php b/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php
index 19ef2ee..e15d3ac 100644
--- a/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php
+++ b/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php
@@ -67,6 +67,7 @@ public function testInstallProfileValidation() {
     $core['module']['testing_config_import'] = 0;
     unset($core['module']['syslog']);
     unset($core['theme']['stark']);
+    $core['theme']['stable'] = 0;
     $core['theme']['classy'] = 0;
     $sync->write('core.extension', $core);
     $sync->deleteAll('syslog.');
diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php
index 0239a41..252684b 100644
--- a/core/modules/system/src/Controller/DbUpdateController.php
+++ b/core/modules/system/src/Controller/DbUpdateController.php
@@ -10,11 +10,14 @@
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Extension\ThemeHandlerInterface;
+use Drupal\Core\Extension\ThemeInstallerInterface;
 use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface;
 use Drupal\Core\Render\BareHtmlPageRendererInterface;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Site\Settings;
 use Drupal\Core\State\StateInterface;
+use Drupal\Core\Theme\ThemeInitializationInterface;
 use Drupal\Core\Update\UpdateRegistry;
 use Drupal\Core\Url;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -82,6 +85,28 @@ class DbUpdateController extends ControllerBase {
    */
   protected $postUpdateRegistry;
 
+
+  /**
+   * The theme initialization.
+   *
+   * @var \Drupal\Core\Theme\ThemeInitializationInterface
+   */
+  protected $themeInitialization;
+
+  /**
+   * The theme handler.
+   *
+   * @var \Drupal\Core\Extension\ThemeHandlerInterface
+   */
+  protected $themeHandler;
+
+  /**
+   * The theme installer.
+   *
+   * @var \Drupal\Core\Extension\ThemeInstallerInterface
+   */
+  protected $themeInstaller;
+
   /**
    * Constructs a new UpdateController.
    *
@@ -101,8 +126,12 @@ class DbUpdateController extends ControllerBase {
    *   The bare HTML page renderer.
    * @param \Drupal\Core\Update\UpdateRegistry $post_update_registry
    *   The post update registry.
+   * @param \Drupal\Core\Theme\ThemeInitializationInterface $theme_initialization
+   *   The theme initialization.
+   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
+   *   The theme handler.
    */
-  public function __construct($root, KeyValueExpirableFactoryInterface $key_value_expirable_factory, CacheBackendInterface $cache, StateInterface $state, ModuleHandlerInterface $module_handler, AccountInterface $account, BareHtmlPageRendererInterface $bare_html_page_renderer, UpdateRegistry $post_update_registry) {
+  public function __construct($root, KeyValueExpirableFactoryInterface $key_value_expirable_factory, CacheBackendInterface $cache, StateInterface $state, ModuleHandlerInterface $module_handler, AccountInterface $account, BareHtmlPageRendererInterface $bare_html_page_renderer, UpdateRegistry $post_update_registry, ThemeInitializationInterface $theme_initialization, ThemeHandlerInterface $theme_handler, ThemeInstallerInterface $theme_installer) {
     $this->root = $root;
     $this->keyValueExpirableFactory = $key_value_expirable_factory;
     $this->cache = $cache;
@@ -111,6 +140,9 @@ public function __construct($root, KeyValueExpirableFactoryInterface $key_value_
     $this->account = $account;
     $this->bareHtmlPageRenderer = $bare_html_page_renderer;
     $this->postUpdateRegistry = $post_update_registry;
+    $this->themeInitialization = $theme_initialization;
+    $this->themeHandler = $theme_handler;
+    $this->themeInstaller = $theme_installer;
   }
 
   /**
@@ -125,7 +157,10 @@ public static function create(ContainerInterface $container) {
       $container->get('module_handler'),
       $container->get('current_user'),
       $container->get('bare_html_page_renderer'),
-      $container->get('update.post_update_registry')
+      $container->get('update.post_update_registry'),
+      $container->get('theme.initialization'),
+      $container->get('theme_handler'),
+      $container->get('theme_installer')
     );
   }
 
@@ -706,4 +741,28 @@ protected function getModuleUpdates() {
     return $return;
   }
 
+
+  /**
+   * Ensures that all the dependencies for theme has been met before proceeding.
+   */
+  protected function ensureThemeDependencies() {
+    $custom_theme = _drupal_get_maintenance_theme();
+    $theme_init = $this->themeInitialization;
+    $theme_handler = $this->themeHandler;
+    $themes = $theme_handler->listInfo();
+    $theme_installer = $this->themeInstaller;
+    // Ensure that at least the maintenance page has a working theme where all of
+    // the parent themes have been enabled.
+    $get_active_theme = function () use ($theme_init, $themes, $theme_handler, $theme_installer, $custom_theme, &$get_active_theme) {
+      try {
+        return $theme_init->getActiveTheme($themes[$custom_theme]);
+      }
+      catch (MissingThemeDependencyException $e) {
+        $theme_installer->install([$e->theme]);
+        $themes = $theme_handler->rebuildThemeData();
+        return $get_active_theme();
+      }
+    };
+  }
+
 }
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index d3b55f9..f746cf0 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -22,6 +22,7 @@
 use Drupal\Core\Extension\ModuleHandler;
 use Drupal\Core\Url;
 use Drupal\Core\Block\BlockPluginInterface;
+use Drupal\Core\Theme\MissingThemeDependencyException;
 use Drupal\user\UserInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use GuzzleHttp\Exception\RequestException;
@@ -523,8 +524,25 @@ function system_page_attachments(array &$page) {
     $page['#attached']['library'][] = 'system/admin';
   }
 
+  // Band-aid.
+  /** @var \Drupal\Core\Theme\ThemeManagerInterface $theme_manager */
+  $theme_manager = \Drupal::theme();
+  /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
+  $theme_handler = \Drupal::service('theme_handler');
+  $get_active_theme = function () use ($theme_manager, $theme_handler, &$get_active_theme) {
+    try {
+      $active_theme = $theme_manager->getActiveTheme();
+      return $active_theme;
+    }
+    catch (MissingThemeDependencyException $e) {
+      $theme_handler->install([$e->theme]);
+      $themes = $theme_handler->rebuildThemeData();
+      return $get_active_theme();
+    }
+  };
+
   // Attach libraries used by this theme.
-  $active_theme = \Drupal::theme()->getActiveTheme();
+  $active_theme = $get_active_theme();
   foreach ($active_theme->getLibraries() as $library) {
     $page['#attached']['library'][] = $library;
   }
diff --git a/core/themes/classy/classy.info.yml b/core/themes/classy/classy.info.yml
index fb5cb3e..7e74173 100644
--- a/core/themes/classy/classy.info.yml
+++ b/core/themes/classy/classy.info.yml
@@ -4,7 +4,6 @@ description: 'A base theme with sensible default CSS classes added. Learn how to
 package: Core
 version: VERSION
 core: 8.x
-base theme: false
 
 libraries:
   - classy/base
