flarum/framework · error · PermissionDeniedException

You cannot disable the default language pack!

Error message

You cannot disable the default language pack!

What it means

Flarum throws PermissionDeniedException from DefaultLanguagePackGuard::handle when an extension being disabled is the language pack that supplies the forum's default locale. The guard listens to the extension disabling event and compares the pack's flarum-locale.code extra field against the default_locale setting. Disabling it would leave the forum without its default language, so the operation is refused.

Solutions

  1. Change the default locale to another installed language pack first (admin panel Appearance/Language settings, or set 'default_locale' in the settings table / config), then disable the old pack.
  2. Install another language pack for the desired locale, switch default_locale to it, then disable the original pack.
  3. If the extension must be removed by script, check its flarum-locale.code against the current default_locale before calling disable and skip or reorder operations.

Example fix

// before: disabling the en pack while default_locale = en
php flarum extension:disable flarum-lang-english

// after: switch default locale first, then disable
php flarum config:set default_locale de  // or update settings table
php flarum extension:disable flarum-lang-english
Defensive patterns

Strategy: try-catch

Validate before calling

// before disabling an extension
$locale = Arr::get($extension->getExtra(), 'flarum-locale.code');
$defaultLocale = $settings->get('default_locale');
$canDisable = $locale === null || $locale !== $defaultLocale;

Try / catch

try {
    $manager->disable($extensionId);
} catch (PermissionDeniedException $e) {
    // switch default_locale first or surface a friendly admin notice
}

Prevention

When it happens

Trigger: Attempting to disable (or uninstall) a language-pack extension whose locale code equals the 'default_locale' setting (e.g. clicking Disable on the 'en' language pack while default_locale is 'en'), via admin panel or the flarum extension:disable console command.

Common situations: Admins cleaning up 'unused' extensions in the dashboard; scripted extension management that disables all non-core extensions; migrating to a new language pack without first switching default_locale.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15). Data as JSON: /api/errors/d956fa4c8fd41a57. Report an issue: GitHub.

Appendix: source

Thrown at framework/core/src/Extension/DefaultLanguagePackGuard.php:34

class DefaultLanguagePackGuard
{
    public function __construct(
        protected SettingsRepositoryInterface $settings
    ) {
    }

    public function handle(Disabling $event): void
    {
        if (! Arr::has($event->extension->extra, 'flarum-locale')) {
            return;
        }

        $defaultLocale = $this->settings->get('default_locale');
        $locale = Arr::get($event->extension->extra, 'flarum-locale.code');

        if ($locale === $defaultLocale) {
            throw new PermissionDeniedException('You cannot disable the default language pack!');
        }
    }
}

View on GitHub (pinned to 4b939f6853)