I'm having an issue switching a previously installed site from a standard profile to a custom one. The idea here is I want to be able to move to a dev environment where I can run install hooks. I've added a single install hook in that profile to see if it's working.

Everything *seems* to be working fine if I run "drush sp my_new_profile", except I keep getting the following error while running drush:

 [warning] The following profile is missing from the file system: my_new_profile bootstrap.inc:276
 [warning] strpos(): Empty needle ExtensionDiscovery.php:295

If I run drush updb, I get the error again, then it asks me to install the db update that's in the module it can't find. Very confusing.

I found reference to this error over in #2867180: Begin work on switching installation profiles in Drupal 8, but I tried upgrading to the dev version, no luck.

My profile is symlinked directly in the profiles directory right off the web root.

I've entirely removed the reference to installation profiles from my settings.php

Any ideas what I'm doing wrong?

Comments

TrevorBradley created an issue. See original summary.

trevorbradley’s picture

Issue summary: View changes
trevorbradley’s picture

Issue summary: View changes
trevorbradley’s picture

OK, digging into this deeper. When I load a page like admin/reports/status, bootstrap.inc loads twice.

The first time is called via SystemManager in drupal_load_updates(), and this loads perfectly fine, because the $extension_list has addedPathNames populated.

The second time through bootstrap.inc is called from ExtensionDiscovery::setProfileDirectoriesFromSettings(). This time around, $extension_list has an empty array for addedPathNames and it fails to pull a directory name for my new profile.

joachim’s picture

No idea, I'm afraid. While I was working on the code around November, I endlessly switched my test site back and forth between core and custom profiles and had no such error.

All I can suggest is you keep investigating!

trevorbradley’s picture

Status: Active » Postponed (maintainer needs more info)

I'll keep at it @joachim. Thanks for the feedback! If I figure it out I'll document it here.

trevorbradley’s picture

Status: Postponed (maintainer needs more info) » Active

OK, got some time to look at this again.

The issue here appears to be that ExtensionList::getPathnames() is failing to call $this->recalculatePathnames(), because the following elseif statement is evaluating as false:

elseif (!$path_names = $this->state->get($cache_id)) {

$this->state has a value for $cache_id = 'system.profile.files', which isn't accurate, so the profile shows up as missing...

If I dig much deeper, I see that State is attempting to call the data from the key_value table, specifically the 'system.profile.files' entry in the database:

select * from key_value where collection = 'state' and name = 'system.profile.files';

This throws back a JSON string that does NOT contain my profile. (but does contain "standard", "minimal" , etc)

| state | system.profile.files | a:14:{s:10:"demo_umami";s:44:"core/profiles/demo_umami/demo_umami.info.yml";s:7:"minimal";s:38:"core/profiles/minimal/minimal.info.yml";s:12:"qcew_profile";s:43:"profiles/qcew_profile/qcew_profile.info.yml";s:8:"standard";s:40:"core/profiles/standard/standard.info.yml";s:7:"testing";s:38:"core/profiles/testing/testing.info.yml";s:21:"testing_config_import";s:66:"core/profiles/testing_config_import/testing_config_import.info.yml";s:24:"testing_config_overrides";s:72:"core/profiles/testing_config_overrides/testing_config_overrides.info.yml";s:40:"testing_install_profile_all_dependencies";s:104:"core/profiles/testing_install_profile_all_dependencies/testing_install_profile_all_dependencies.info.yml";s:36:"testing_install_profile_dependencies";s:96:"core/profiles/testing_install_profile_dependencies/testing_install_profile_dependencies.info.yml";s:39:"testing_install_profile_dependencies_bc";s:102:"core/profiles/testing_install_profile_dependencies_bc/testing_install_profile_dependencies_bc.info.yml";s:28:"testing_missing_dependencies";s:80:"core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml";s:20:"testing_multilingual";s:64:"core/profiles/testing_multilingual/testing_multilingual.info.yml";s:33:"testing_multilingual_with_english";s:90:"core/profiles/testing_multilingual_with_english/testing_multilingual_with_english.info.yml";s:20:"testing_requirements";s:64:"core/profiles/testing_requirements/testing_requirements.info.yml";} |

I tried a crazy thing in SQL, hoping this cached key_value would get rebuilt if it were missing:

delete from key_value where collection = 'state' and name = 'system.profile.files';

Refresh a web page throwing the error, and then run...

select * from key_value where collection = 'state' and name = 'system.profile.files';

BAM, the profile is listed in the database row, and the error dissapears completely.

So, in summary, somehow I have stale data in the key_value table entry for system.profile.files, which isn't pulling in my new profile.

Any ideas why this bad data would be there for me, and not for everyone else?

trevorbradley’s picture

If anyone else is getting stuck on this, try the following command before running drush sp (profile_name):

drush sqlq "delete from key_value where collection = 'state' and name = 'system.profile.files';"

Just tried it on a fresh reset of my docksal and it worked beautifully.

trevorbradley’s picture

Category: Support request » Bug report
skaught’s picture

StatusFileSize
new1.03 KB

patch based on #8.
this works from drush command... except for a final cache-rebuild needs to be run. I can't currently find a way to run that from the command.

joachim’s picture

Status: Active » Needs work

Thanks for the patch.

Remember to set an issue to 'needs review' when you post one though!

A few points:

  1. +++ b/src/ProfileSwitcher.php
    @@ -56,6 +56,14 @@ class ProfileSwitcher {
    +    // issue #3022775
    

    There's no need to reference an issue when you're fixing something. If anyone ever needs to know why a line of code is there, they can use git blame and the commit message will lead them here.

    What would however be useful is a comment explaining what we're doing.

  2. +++ b/src/ProfileSwitcher.php
    @@ -56,6 +56,14 @@ class ProfileSwitcher {
    +    $connection = \Drupal::database();
    

    Isn't the current class a service? If so, this can be injected.

  3. +++ b/src/ProfileSwitcher.php
    @@ -56,6 +56,14 @@ class ProfileSwitcher {
    +    $connection->delete('key_value')
    +      ->condition('collection', 'state')
    +      ->condition('name', 'system.profile.files')
    +      ->execute();
    +    drupal_flush_all_caches();
    

    Why do we need to delete from the state and then also flush all caches?

  4. +++ b/src/ProfileSwitcher.php
    @@ -56,6 +56,14 @@ class ProfileSwitcher {
    +      ->condition('collection', 'state')
    

    Isn't there an API to use the state?

nterbogt’s picture

Here is my rewritten patch based on the comments above. I can confirm that the additional cache reset was not required.

nterbogt’s picture

Status: Needs work » Needs review

Sorry, needs review again now.

  • joachim committed 5e2d058 on 8.x-1.x authored by nterbogt
    Issue #3022775 by nterbogt, SKAUGHT: Fixed warning about profile missing...
joachim’s picture

Status: Needs review » Fixed

That looks great.

Thanks everyone!

Status: Fixed » Closed (fixed)

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