Impossible to site-install --config-dir with any profile other than minimal
Closed this issue ยท 25 comments
As of #1921 and Drush 9, it's impossible to install a site using the config-dir
parameter and any profile other than minimal.
This was apparently an intentional change to fix problems with UUID changes and content imports, but it had the side effect of basically breaking any profile other than minimal.
The problem is that once a site is installed with a given profile, you generally cannot change that profile via a configuration import. Attempting to do so results in all sorts of error messages like this:
Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in Drupal\Core\Config\ConfigImporter->validate() (line 728 of /var/www/foo/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php).
[error] The import failed due to the following reasons:
Unable to install the bar module since it does not exist.
Cannot change the install profile from foo to minimal once Drupal is installed.
Furthermore, when Drush forces the install profile to be minimal
, that overwrites any value of $settings['install_profile']
in settings.php to also be minimal
. This could cause all kinds of problems. For instance, on read-only file systems, the install will completely fail. For other file systems, it will prevent you from changing to any other install profile, even if the config-import were successful. In fact, this might actually be what's generating the error message above (note that it's trying to change from a custom profile back to minimal for some reason).
I definitely think the original issue in #1921 needs to be solved, but not by forcing the install profile to be minimal. It's something that likely needs to be fixed upstream in Drupal core.
Shoot, I spent quite a bit of time figuring out how to make this work some time ago, but now I can't remember exactly what was necessary.
The reason I can't remember is that I decided it wasn't worth the complexity, when the config installer profile exists (and hopefully someday is heading to core). Now, I just use config installer, which works with any profile.
The Config Installer profile is completely undocumented, can you propose how to use it to install something like a Lightning sub-profile? AFAICT, that's impossible.
I think I did that, but my PR is out of date, and probably not working right now. It's not using config installer at the moment, though, so I'm not sure whether I did or did not try that permutation.
It looks like the Config Installer profile makes an exception and scans the directory of the profile listed in core.extensions.yml for extensions in addition to the regular places Drupal would look for extensions.
Unfortunately, if your site is using the core patch to allow for inherited profiles, there might be more than one profile directory that contains extensions to be enabled. And the Config Installer profile will fail during install because it can't find those extensions.
I wouldn't expect Config Installer to be making that exception for parent profiles, just noting that it won't work with a profile like Lightning that contains extensions and is generally used as a base profile.
/cc @danepowell
Forcing minimal seems really messy especially the install profile is stored in config now.
I'd love some guidance from folks about how to proceed.
IIRC, the forcing of 'minimal' came after a steady stream of support requests from people trying to use --config-dir with standard profile. They were getting something like 'shortcut content must be deleted' before import'
Well ideally we'd have https://www.drupal.org/node/2788777 in core and we'd just move https://www.drupal.org/project/install_profile_generator into core drush and then people could create their own install profiles.
Basically config import was not designed to work the way drush is using it. A potential solution would be for drush to install minimal, delete all config entities, swap the profile to the one from config, and then do the config import.
Sounds good. PRs appreciated.
Anyone?
For those trying to solve the problem of installing a site from config, the Configuration installer profile works quite nicely. I've tested and documented our usage of it here: http://lightning.acquia.com/blog/using-configuration-installer-lightning
Ultimately, I think this is the parent issue https://www.drupal.org/project/drupal/issues/1613424
At the very least I think we should add a warning if a profile is specified along with --config-dir
? It would save me from learning this lesson anew every 6 months ;-)
try drupal 8.6 and drush si's new --existing-config option.
@weitzman How come it is not on the documentation?
Isn't that being automatically generated from the code annotations? I'll be glad to help with that if we need to update something ๐
Thats not official documentation. Thats a 3rd party site that is rarely updated.
@weitzman - That 3rd party, site, unfortunately, is the #1 search result for almost any kind of drush-related query on Google. Is there any chance it could be adopted or subsumed by the project?
The fact that it's also the first link relating to Drush Commands on the official docs site lends credence and also can lead to some confusion :/
Also just noting that when --existing-config
is used with the standard install profile you still hit:
In install.core.inc line 2289:
Configuration install: standard
The selected profile has a hook_install() implementation and therefore can not be installed from configuration.
Drupal.org issue, for reference: Allow an install hook in profiles installing from configuration. So for now the only real option to use Drush/Drupal's built-in install-from-config option is to use minimal as your install profile, or some other very simple profile, and do any non-config-related work via some other mechanism (e.g. default_content, migrations, individual module install hooks, etc.).
@geerlingguy you can use https://www.drupal.org/project/config_installer . This is what I'm doing, and it works great.
Is there any chance it could be adopted or subsumed by the project?
I've asked. It was a while ago. If someone could make that happen I'd love to receive that site ... i've removed the docs links.
try drupal 8.6 and drush si's new --existing-config option.
@weitzman How do you specify config dir? on drupal 8.8.x
in settings.php you would need $settings['config_sync_directory']
If anyone else runs into this and wants a quick fix, delete the install hook from standard profile for a second and it runs fine. :)
Should this issue be closed? It's not fixed as far as I can tell.
When I run:
drush site-install -y --existing-config
I get:
In install.core.inc line 2304:
Configuration install: standard
The selected profile has a hook_install() implementation and therefore can not be installed from configuration.
Database settings:
Array
Its closed because the limitation comes from Drupal core, not Drush
Got it, thank you.
Should this issue be closed? It's not fixed as far as I can tell.
When I run:
drush site-install -y --existing-config
I get:
In install.core.inc line 2304: Configuration install: standard The selected profile has a hook_install() implementation and therefore can not be installed from configuration. Database settings: Array
You need to update your core.extension.yml on 2 lines: https://www.hashbangcode.com/article/drupal-8-install-site-existing-configuration