Problem/Motivation
Projects namespaced in their own custom profile are a common pattern in Drupal development. In such cases custom modules, themes and libraries are placed inside the custom profile.
Scenario: As a site builder I want to be able to use my custom profile namespace while still being able to import configuration with config_installer
.
Steps:
- Environment: Drupal 8.1.2, Configuration installer 8.x-1.3.
- In the codebase I have a custom profile at
profiles/myprofile
. At this stage the profile is empty (contains only themyprofile.info.yml
file). - Before installing Drupal, I'm adding my custom profile and config sync dir in settings.php:
$config_directories['sync'] = 'config/sync'; $settings['install_profile'] = 'myprofile';
- I'm running
drush si config_installer (...)
Everything is OK at this stage, the site installs successfully.
Then I'm starting to add custom modules and themes to profiles/myprofile
. Let's say I'm adding a custom theme in profiles/myprofile/themes/mytheme
. These custom extensions are creating their own configs and are making other configs depending on them. I'm exporting the config again to sync directory defined above in $config_directories['sync']
and I'm reinstalling the site in the same way. But now config import fails:
Unable to install the mytheme theme since it does not exist.
array_keys() expects parameter 1 to be array, null given in Drupal\Core\EventSubscriber\ConfigImportSubscriber->validateModules() (line 99 of
core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php).
... (removed error trace for readability)
Unable to install the myprofile module since it does not exist.
The configuration synchronization failed validation.
Proposed resolution
To be defined.
It seems that \Drupal\config_installer\Storage\SourceStorage::read()
should exclude also all configuration depending on extensions introduced by profiles and then install them later?
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#18 | 2747179-17.patch | 12.88 KB | alexpott |
#17 | 2747179-17.patch | 3.79 KB | alexpott |
#17 | 13-17-interdiff.txt | 1.27 KB | alexpott |
#13 | 2747179-13.patch | 10.6 KB | plopesc |
#13 | 2747179-13-test-only.patch | 9.06 KB | plopesc |
Comments
Comment #2
claudiu.cristeaComment #3
lukewertzRight, so this becomes an issue when using any profile that includes sub-modules... In my case, Acquia's Lightning cannot be installed with config_installer.
Comment #4
sylvainar CreditAttribution: sylvainar commentedStill struggling on this. Does any of you found a solution ?
Comment #5
alexpottThe best solution here is to get #2788777: Allow a site-specific profile to be installed from existing config done. Implementing this in contrib requires us to switch out profiles which makes scanning for modules extremely tricky.
Comment #6
plopescI experienced this problem when trying to use this profile to rebuild the project, but the original profile contains modules in it.
The install process threw an exception -
Unable to install the %module module since it does not exist.
- because it was not able to find that module.After some debugging, I found that problem was that
ConfigImportSubscriber::getModuleData()
calls tosystem_rebuild_module_data()
that relies on$install_state
global variable.So, to bypass this false error, here I'm proposing a patch to swap the value of
$install_state['parameters']['profile']
to adapt the profile value and pass this validation.After the validation, this value is reverted back and the process continue smoothly.
Thank you.
Comment #7
plopescUpdated version of the patch.
Comment #8
alexpottIt'd be great to add a test for this.
Comment #9
plopescAttaching the previous patch includiing new tests to prove that works.
While working on this, I had to fix a couple of bugs I found in the module related to Symfony upgrade #2949774: Tarball upload feature is broken due to Symfony upgrade and how to handle module test fixture files #2949778: Remove pre 8.3 tarballs for testing.
In order to test this issue, the 2 mentioned above should be merged before.
Thank you.
Comment #10
hawkeye.twolfFYI, the patch in number #9 differs from the patch in #6 on one line; missing the declaration of
global $install_state
. I haven't actually looked at the code to see if that's needed or not. Also, I tried both patches, and neither solved the issue for me when trying to install with a set of configuration exported from a site originally installed with the lightning profile. The configuration files don't pass validation because oflightning.versions.yml
anduser.role.layout_manager.yml
.Comment #11
alexpott@plopesc thanks for fixing the tests on 8.4.x! I've committed your patches and fix another thing. Tests are now green on 8.4.x and 8.5.x. Nice one.
Comment #12
alexpottThere's no 8.3 fixtures anymore since 8.3 is not supported. All the fixtures are for 8.4.x / 8.5.x
Comment #13
plopescHello, as @derek.deraps mentioned above, I forgot to include one line in the #9 patch. I was working in 3 issues at the same time and messed up my git diffs :)
Here I'm attaching a re-roll of that patch taking into account your last commits and also adding back that missing line.
Regarding fails mentioned in #10, I only have to say that we have this patch working in a couple of real projects where we have custom profiles including nested modules, and tests are green.
Could you please provide more info to try to trace those errors you are still having with lightning?
thank you
Comment #14
hawkeye.twolf@plopesc, thank you much. I ended up just working around the issue for now (standard site install, set the site UUID, then run a normal config import) but if I find some time to jam on the issue later and recreate it in a vanilla environment, I'll report back. Cheers!
Comment #15
MorinLuc0 CreditAttribution: MorinLuc0 as a volunteer and at Coldfront Labs Inc. commentedThe issue that @derek.deraps is running into is a lightning specific problem. I received the same error.
See issue 2933445
I applied the lightning patch and this patch and I was able to use the config_installer to install a profile previously installed with lightning.
I have marked the issue RTBC unless there is any other work that needs to be finished for this issue ?
Comment #16
alexpottThis test should also test that 'Nested module' is installed. I'm pretty sure that is it enabled in the db dump but an explicit assertion would also be good. Override \Drupal\config_installer\Tests\ConfigInstallerTestBase::testInstaller() and call the parent but add an assertion about the module being installed.
Also I['m guessing you copied from ConfigInstallerNoDependenciesProfile but actually tests by convention should end in "Test".
Comment #17
alexpottFixed #16
Comment #18
alexpottForgot to diff with --binary.
Comment #19
alexpottCreated @claudiu.cristea for creating the issue.
Comment #20
alexpottAll tests pass
Comment #23
Elin Yordanov CreditAttribution: Elin Yordanov commentedThis patch doesn't fix the issue with the themes provided by a profile. I still get the error:
> Unable to install the %theme theme since it does not exist.
Also see the related issue #2975675: Themes provided by profiles not recognized when importing config. May be it should be closed as a duplicate of this issue and this issue should be reopened, since the committed fix is incomplete?
Comment #24
alexpott@Елин Й. no need to re-open this issue. We can just note that #2975675: Themes provided by profiles not recognized when importing config is completing the fix. That issue needs a test written.
Comment #25
eelkeblokIt looks like there is at least something left here, because I was having trouble installing my custom profile and getting the same error message as mentioned in the summary. I then noticed the patch which removed the known limitation that config_installer will not work with profiles containing modules. Since my profile does include modules, this seemed too much coincidence, so I removed the modules.
Lo and behold, the site installed then without any problems.Edit: Sorry, the submodules were a red herring. Am getting the "can not install [my profile] module because it does not exist", though, not sure why. Very complicated to debug, looking into moving to using the core option directly.