Score:3

Moved an old installation profile now site is broken

do flag

I have a d9 site with an old installation profile originally written for d8.

I was having some issues with the profile preventing the uninstallation of some modules so I tried moving the entire folder for a moment to see if that removed the profile.

Instead, it broke (WoD) the site. I moved the profile directory right back where it was but no matter what I do the site remains WoD with the message:

the profile myprofile does not exist

The directory and all the files are there. Drush just keeps throwing that error. How can I fix this?

Just to be clear: I understand I should not have moved the directory. My question is how to get the site working again. In effect, what I did was:

  1. Move the profile outside of web/profiles
  2. visit the site + try to clear the cache with drush
  3. Moved the profile back to web/profiles

The site will not work now. With modules and themes if the files are moved and replaced the site looks for them when they return, why will it not do this for the profile? Is there some entry in the DB indicating the profile is gone - if there is why would there be such a thing?

tz flag
Restoring a backup of the db from before the move will help and than you can create a development environment to try do what you want without fear of breaking anything.
Score:4
cn flag

A profile is like a module or theme, you have to uninstall it first before you can remove it from the file system. Additionally a profile can't just be uninstalled like a module. You need to switch the profile. This module might be helpful:

Profile Switcher

This module provides a Drush command to switch between install profiles found in /profile directory:

drush switch:profile [new-profile]

This is useful for moving an existing site to distribution or moving from an abandoned distribution back to a standard Drupal core install.

https://www.drupal.org/project/profile_switcher

See the warnings, though:

IMPORTANT WARNINGS:

  • Switching profiles is NOT a trivial change like switching a theme.
  • ALWAYS test before using on a live site and ALWAYS have a backup

Recover broken site

After moving the profile back to web/profiles you can recover a broken site by resetting the extension profile list:

drush ev "\Drupal::service('extension.list.profile')->reset();"

This not only clears the relevant cache entries but also the key system.profile.files stored in the State API.

Instead of the drush command you can clear the cache_ tables and the entry system.profile.files in the collection state from the key_value table:

delete from 'key_value' where collection = 'state' and name = 'system.profile.files';
do flag
I can't add a module. I can't do anything. The site is WoD and Drush errors on all commands. I have replaced the files so I really don't understand why it keeps erroring but I cannot do anything at this point
cn flag
Clearing cache twice should be enough to bring the site back. If it doesn't, it's still repairable if you have a custom module installed which you can edit the .install file for
do flag
I cannot access any page - logged in or not - or use any command via Drush. The site is completely WoD ("The site has encountered an error...") I have even tried manually clearing all the caches with an sql query; all pages on the site remain inaccessible. Why would this be happening?
cn flag
I don't know the dirty details, but Drupal is overly sensitive to the profile being moved, I've been in the same position you're in a couple of times before. Truncating the cache tables has nearly always worked, the one time it didn't I had to add a `hook_update_N` function to correct things. That function basically mimicked what the profile_switcher module does in manipulating core.extension.yml and I think one other bit of config to get the references to the new profile set up. `updb` should still run no matter how borked the site is
do flag
I'm not even trying to change profiles at this point. I've literally put all the files back. Is there somewhere I can manually set the profile path so it can find it again?
4uk4 avatar
cn flag
@tanbog, I've added a drush command you can try.
do flag
Doesnt work. Looking at the drush debug output it never gets as far as even trying the command (or any command) it fails in the pre-flight. I think I am going to have to rebuild the site from an older backup on a staging/test server. Moving some files for a moment should not destroy a site...
4uk4 avatar
cn flag
Then there is something else wrong, I've reproduced the error with the steps you've described on a test site with a contrib profile and while `drush cr` threw the error, the `drush ev ...` did run without error and recovered the site.
4uk4 avatar
cn flag
I was also able to recover the site manually in the database. See the edit.
do flag
That last one worked. Removing the profile file reference in the db: `delete from 'key_value' where collection = 'state' and name = 'system.profile.files';` omg thanks so much.
Score:2
cn flag

There's an approach to fix your problem which doesn't involve switching the profile at all:

Edit the profile's .info.yml file, and change the key for the list of modules from required to install. This will let you uninstall the modules, while still keeping them associated with that profile.

do flag
I realised this "after" moving the profile. If I can repair my sight I will use that apparoach
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.