diff --git a/core/includes/install.inc b/core/includes/install.inc
index c9fd75d..196145f 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -939,6 +939,9 @@ function drupal_check_profile($profile, array $install_state) {
   $listing = new ExtensionDiscovery(\Drupal::root());
   $module_list = $listing->scan('module');
   foreach ($info['dependencies'] as $module) {
+    if (!array_key_exists($module, $module_list)) {
+      throw new \Exception("The ${info['name']} profile depends on the missing module $module.");
+    }
     $file = \Drupal::root() . '/' . $module_list[$module]->getPath() . "/$module.install";
     if (is_file($file)) {
       require_once $file;
