When trying to install a profile containing configuration files from a Drupal 8.1.x site, the installation fails with the following error:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd8.key_value' doesn't exist: SELECT 1 AS expression FROM {key_value} key_value WHERE ( (name = :db_condition_placeholder_0) AND (collection = :db_condition_placeholder_1) ); Array ( [:db_condition_placeholder_0] => routing.menu_masks.router [:db_condition_placeholder_1] => state ) in Drupal\Core\State\State->set() (line 84 of /var/www/drupalvm/d8/core/lib/Drupal/Core/State/State.php).

Drupal\Core\State\State->set('routing.menu_masks.router', Array) (Line: 154)
Drupal\Core\Routing\MatcherDumper->dump(Array) (Line: 84)
Drupal\Core\ProxyClass\Routing\MatcherDumper->dump() (Line: 189)
Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 626)
drupal_install_system(Array) (Line: 1035)
install_base_system(Array) (Line: 658)
install_run_task(Array, Array) (Line: 536)
install_run_tasks(Array) (Line: 115)
install_drupal(Object) (Line: 39)

If the config files are deleted from the profile directory, the installation succeeds, and the key_value table is created.

If one or two of the simpler config files, e.g. system.theme.yml, are restored, the installation also succeeds.

Comments

malcomio created an issue. See original summary.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

markaspot’s picture

Maybe check if the core.extension.yml is part of your configuration. Deleting this from the installation directory helped me getting rid of this kind of error.

malcomio’s picture

Title: Exception when installing profiles with configuration - key_value table does not extist » Exception when installing profiles with configuration - key_value table does not exist
Category: Bug report » Support request

Thanks - that seems to have done the trick (at least for that error on my install).

It should probably be documented somewhere - with the docs changes, I'm not quite sure where though...

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

larowlan’s picture

Status: Active » Fixed

Thanks, for this.

Adding some more keywords for google and closing

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'key_value' doesn't exist

Status: Fixed » Closed (fixed)

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

lord_of_freaks’s picture

Worked for me too in 8.5.2 Thanks!

timmillwood’s picture

Status: Closed (fixed) » Active

Over the past week we've been hitting this same issue with several sites.

Deleting core.extension.yml is not really an option. We're building sites then locally, committing all config along with contrib/custom modules to an install profile, then deploying to server and running a site install, where we get the same "'key_value' doesn't exist" issue. Therefore we want to keep the core.extension.yml config to make sure all modules are enabled on install.

Note: We're running Core 8.5.x with a patch from [#2788777#97], but actively working on testing core 8.6.x where we're also seeing the issue.

vijaycs85’s picture

Category: Support request » Bug report
lpeabody’s picture

I am also running into this issue and it's preventing site installs. We're built up on Acquia Cloud Site Factory, so we have many sites sharing the same set of configuration used for both installing new sites as well as updating existing sites, so removing core.extension.yml is simply not an option.

Given that install from config is supported by core now, and you can't actually install from existing config on 8.6.x, I think this should probably be critical, yes?

EDIT: False positive. You get a giant stack trace with the error, but if you scroll up more you might see something like:

  [Drupal\Core\Installer\Exception\InstallerException]                                                             
  Configuration install: bax_portfolio                                                                             
                                                                                                                   
  The selected profile has a hook_install() implementation and therefore can not be installed from configuration.

So turns out you can't have hook_install if you're installing from config (makes sense I guess).

If your site install command is part of a script that does a cache-clear after the install (like mine does), then you would see the key_value error reported in the description.

Just wanted to post that in case other people ran into something similar and found their way here.

SocialNicheGuru’s picture

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

oheller’s picture

Version: 8.9.x-dev » 9.1.x-dev

This is still relevant today. The solution #3: delete core.extension.yml from myprofile/config/install solved my issue. I also needed to make sure all the modules and themes in core.extension.yml where in myprofile.info.yml.

See https://www.drupal.org/docs/distributions/creating-distributions/how-to-...

Version: 9.1.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

colan’s picture

The problem does indeed seem to be that core.extension.yml conflicts with the installation profile's info.yml. Logically, it doesn't even make sense to have both because they both do the same thing, decide which modules and themes get enabled. So how would the system know which one to use?

#13 sounds like a red herring as we have one of those and it still works.

So I think the best way to fix this is to have some kind of check. If both of those files are there, issue an error stating that you can have only one, but not both. This is much better UX than crashing further down, forcing the user to do a Web search with the error, and then coming here.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.