So I have switched to the developer mode while developing on a Magento 2 project using the following command:
php bin/magento deploy:mode:set developer
All good, I got this message and I developed the website fine:
Current application mode: developer.
For some reasons, I wanted to go back to the default
mode just to check the behavior of the website in this mode. No specific reasons to be honest, I just wanted to switch back to this mode.
So I ran the following command:
php bin/magento deploy:mode:set default
But I got this weird error with no further explanations:
Cannot switch into given mode "default"
I checked the following file that handles the mode settings Magento/Deploy/Console/Command/SetModeCommand.php
and here's what I've found:
switch($toMode) {
case State::MODE_DEVELOPER:
$modeController->enableDeveloperMode();
break;
case State::MODE_PRODUCTION:
if ($skipCompilation) {
$modeController->enableProductionModeMinimal();
} else {
$modeController->enableProductionMode();
}
break;
default:
throw new LocalizedException(__('Cannot switch into given mode "%1"', $toMode));
}
How weird is that, Magento 2 is shipped in default mode but you can't switch back to that specific mode. What's the reason behind this ?
Edit: for those interested I ended up creating an issue on github: https://github.com/magento/magento2/issues/4292