3

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?

1
  • 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.
    – GiorgosK
    Jan 20, 2023 at 10:58

2 Answers 2

4

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';
10
  • 2
    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
    – Clive
    Jan 19, 2023 at 11:57
  • 1
    @tanbog, I've added a drush command you can try.
    – 4uk4
    Jan 19, 2023 at 12:36
  • 1
    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
    Jan 20, 2023 at 8:14
  • 1
    I was also able to recover the site manually in the database. See the edit.
    – 4uk4
    Jan 20, 2023 at 8:34
  • 1
    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.
    – tanbog
    Jan 20, 2023 at 8:53
2

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.

1
  • I realised this "after" moving the profile. If I can repair my sight I will use that apparoach
    – tanbog
    Jan 19, 2023 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.