32

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

  • 1
    It is very good question, and we were gathering feedback why would you want to use default mode, but not developer. And seems like you define the reason as "No specific reasons". But I agree - we must allow to on/off the mode, since it is by default. At the moment we have in our backlog task to add it in list possible modes. – maksek Apr 25 '16 at 13:23
  • 6
    One reason would be: I have developed an extension and some of my customers might be running in default mode – Kristof at Fooman Apr 25 '16 at 13:40
33

The default mode is neither here nor there.

mode overview

The Magento team really wants you to use either Production Mode on your live site or Developer Mode during Development. The reason why Default Mode exists is to have something that would at least run reasonably when deployed directly from the downloaded code without further intervention.

By running php bin/magento deploy:mode:set you have identified yourself as capable and not needing the default mode. As there is no reason needing to go back to default mode Magento did not provide a way for you to do so.

  • 6
    I knew I should have taken that picture. By the way you were sitting 5-6 chairs on my left :) – Marius Apr 25 '16 at 14:09
  • 1
    Ended up creating an issue: github.com/magento/magento2/issues/4292 – Raphael at Digital Pianism Apr 25 '16 at 14:24
  • 2
    The reason you are one vote ahead is because I upvoted you :). – Marius Apr 25 '16 at 14:28
  • 3
    The reason Marius is behind is I downvoted him :-P – philwinkle Apr 25 '16 at 19:42
  • 3
    The reason wanting to switch back to "Default" mode is clearly because "developer" mode is too slow. Testing your page is an important part of development and should not be slowed down nor have the need to fully deploy everything using "production" mode. As a developer I chose rather to suffer the downsides of "default" mode than being forced to decide between "developer" and "production" – leedch May 22 '17 at 13:03
18

The default mode is there only to install Magento 2.
It should not be used for development or production.
After installation you can only switch between dev and prod.

Source: Alan Kent @MagentoImagine2016

10

As a windows developer, in developer mode, Magento wants to create symbolic links to the static assets, but uses the Linux command and not the windows command. This creates a lot of errors in the js and css files.

To switch back to default mode, open:-

app/etc/env.php

And change:-

'MAGE_MODE' => 'developer',

Back to:-

'MAGE_MODE' => 'default',

And re-deploy static files again.

  • Note: Environment variables may override this value. – Elzo Valugi Aug 7 '17 at 13:34
  • 1
    Note that Magento doesn't officially support Windows, so trying to develop on Windows could produce other problems as well. – ProcessEight Jul 30 '18 at 8:59
1

I ran with the same problem, but changing it in env.php manually works.

  • Yeah of course I know I could it directly I was just wondering why it's not possible via the CLI – Raphael at Digital Pianism Apr 25 '16 at 13:30
0

**set mode 2.3.x**

Now Magento allowing us to switch back to default mode from 2.3.x

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