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
- 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.
- Install another language pack for the desired locale, switch default_locale to it, then disable the original pack.
- 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
- Always install at least two language packs before disabling any of them.
- Check flarum-locale.code against default_locale in automation scripts before disabling.
- Switch default_locale as part of the migration runbook, not after cleanup.
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
- Paths are not possible in websocket connections.
- ValidationException (messages from password validator)
- core.admin.appearance.custom_styles_cannot_use_less_features
- custom_less
- validation. (translated message for )
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)