50

I'm trying to install Magento 2 but I am getting the following error:

Error happened during application run. Could not write error message to log. Please use developer mode to see the message.

I have tried adding SetEnv MAGE_MODE developer to .htaccess as advised by Alan Storm http://magento-quickies.alanstorm.com/post/58757471044/magento-2-developer-mode but no luck.

4
  • Are you using apache or nginx? How exactly did you set the environmental variable?
    – user487772
    Jan 14, 2014 at 15:20
  • @Tim I am using Apache. I set it by adding it to the top of the .htaccess Jan 14, 2014 at 15:28
  • Adding what? Please add all this info into your question.
    – user487772
    Jan 14, 2014 at 19:01
  • You will have to have mod_env enabled for Apache and AllowOverride On in your vhost configuration in order for .htaccess to be parsed.
    – benmarks
    Jan 14, 2014 at 19:04

15 Answers 15

96

you can enable it from the cli

bin/magento deploy:mode:set developer

36

Another way, we can enable developer mode

  • Goto app/etc/ and open env.php
  • and change current application mode by MAGE_MODE' => 'default' to MAGE_MODE' => 'developer'

Then,please flush the cache

18

As you and others have noted:

SetEnv MAGE_MODE "developer"

in your .htaccess file should enable developer mode assuming that AllowOverride All is in the proper <Directory> directive.

Related to your original problem though, it might be due to a permissions issue where the Apache process user does not have write permissions to the right directories.

For a quick test, you can do the following inside your Magento 2 directory:

chmod -R a+wX var
chmod -R a+wX app/etc
chmod -R a+wX pub

Then if the installation wizard pops up, you can try to make sure you have the correct permissions for your Apache process on those directories.

1
8

Are you using mod_fastcgi + php-fpm? I ran into this issue as in that environment. The environment variable was getting prefixed with "REDIRECT_".

Related question on stack exchange here: Apache SetEnv prepends REDIRECT_ . What gives?

I was able to resolve this by just setting the environment variable in the php-fpm pool configuration file:

env[MAGE_MODE] = developer
8

In order to change magento 2.0 mode you have to run this command php bin/magento deploy:mode:set developer in CMD or your SSH windows into magento 2.0 root folder. More information you can find here and here.

5

Go to your magento root folder from command prompt and excecute below comand:

php bin/magento deploy:mode:set developer

4

If you're using the built-in web server in PHP 5.4 you need to set the ENV when starting up the server:

MAGE_MODE=developer php -d variables_order=EGPCS -S 127.0.0.1:8080 router.php

For more information on how to use PHP 5.4's built-in webserver, including setup of Magento 2 see this screencast:

http://quick.as/kkbahnlx

4

Please try by adding the following line inside index.php at the beginning file.

$_SERVER['MAGE_MODE'] = 'developer';

Hope you will see the error message.

2
  • 4
    I would highly discourage to edit core files like the index.php
    – 7ochem
    May 20, 2015 at 12:02
  • 1
    I believe this should be out of repo either way, so once you change it on local will not really do too much bad. Jun 14, 2016 at 10:30
4

Hi I have read your question and please see solution.

You can set developer mode by CLI command and also manually

To set it manually:

open your magento 2 root directory, Open file "/app/etc/env.php" and search "'MAGE_MODE' =>". you can change magento mode here manually.

CLI command for production mode:

magento deploy:mode:set production

CLI command for developer mode:

magento deploy:mode:set developer

for more information please visit below URL. http://php-scripts-form.blogspot.nl/2017/09/magento-2-how-to-set-production-mode.html

2
  • How can I see the mode before changing it? Nov 22, 2017 at 13:56
  • @RazvanZamfir you can use deploy:mode:show to see the current mode. Dec 22, 2017 at 20:36
3

If you are using NginX as the web server... .htaccess won't affect. Changing the NginX Server Directives will enable the developer mode.

for example: /etc/nginx/sites-available/m2_test.conf (Assuming nginx is properly configured)

server {
   listen 80;
   server_name m2.test.com;
   set $MAGE_ROOT path/to/magento2;
   set $MAGE_MODE developer;
   include other/configurations/file.conf;
}

This set $MAGE_MODE will turn on the developer mode.

other/configurations/file.conf should link to the configurations file path which should be a copy of [MAGENTO_DOC_ROOT]/nginx.conf.sample

As others have mentioned, php bin/magento deploy:mode:set developer also will enable it

1
  • have i to set developer mode in both nginx conf and from magento console? What happens if one is developer and one production?
    – LucScu
    Sep 27, 2016 at 9:38
3

When you change from production to developer mode, you should clear generated classes and Object Manager entities like proxies to prevent unexpected errors. After doing so, you can change modes. Use the following steps:

  1. If you’re changing from production mode to developer mode, delete the contents of the var/generation and var/di directories:

    rm -rf <your Magento install dir>/var/di/* <your Magento install dir>/var/generation/* 
    
  2. Set the mode:

    magento deploy:mode:set developer
    

Following message will be displayed

   Switched to developer mode.
1

Enable/ Disable Magento 2 Developer Mode

What is Developer Mode The Developer mode of Magento is the mode you will use when you need to customize your Magento 2 or when you want to install extensions. More specifically, it will be used in the following situations:

Publish a symlink of each required file to the pub/static directory Uncaught exceptions are seen in the browser The system logging in var/report is verbal. Put the exception into the error handler Generate the exception if an event subscriber cannot be enforced. Magento 2 Check Developer Mode To check the current mode, the following command needs to be run as the Magento file system owner:

bin/magento deploy:mode:show

If you have shared hosting, this would be the user which your provider gives you to log in to the server. On the contrary, if your server is private, it’s a local user account on the Magento server.

After you have run the above command, a message which is similar to this will be displayed:

Current application mode: {mode}. Note: Environment variables may override this value. And the {mode} can be the default, developer, or production.

Enable Magento 2 Developer Mode Before enabling the Developer Mode, you need to ensure that generated classes and Object Manager entities like proxies have been clear. Otherwise, unexpected errors might probably occur. Once you have clear them, you can start changing your mode from production to developer by following these steps:

Step 1: In this first step, delete the generated/code and generated/metadata directories’ contents: rm -rf /generated/metadata/* /generated/code/* Step 2: Next, you can set the mode: bin/magento deploy:mode:set developer After the mode has been set, you will see the following message:

Enabled developer mode. Disable Magento 2 Developer mode Above I have just shown you the method to enable Developer mode. However, in various situations, you would need to change the mode back from Developer to Production. And this is how you do it:

Firstly, set the mode to Production.

bin/magento deploy:mode:set production After you have set the mode, you will see messages which are similar this:

Enabled maintenance mode Requested languages: en_US === frontend -> Magento/luma -> en_US === ... more ... Successful: 1884 files; errors: 0

=== frontend -> Magento/blank -> en_US === ... more ... Successful: 1828 files; errors: 0

=== adminhtml -> Magento/backend -> en_US === ... more ...

=== Minify templates === ... more ... Successful: 897 files modified

New version of deployed files: 1440461332 Static content deployment complete Gathering css/styles-m.less sources. Successfully processed LESS and/or Sass files CSS deployment complete Generated classes: Magento\Sales\Api\Data\CreditmemoCommentInterfacePersistor Magento\Sales\Api\Data\CreditmemoCommentInterfaceFactory Magento\Sales\Api\Data\CreditmemoCommentSearchResultInterfaceFactory Magento\Sales\Api\Data\CreditmemoComment\Repository Magento\Sales\Api\Data\CreditmemoItemInterfacePersistor ... more ... Compilation complete Disabled maintenance mode Enabled production mode. Conclusion In conclusion, the Developer mode which the Magento 2 platform offers is essential for store owners in various particular situations. I hope the above information can provide you the necessary details for activating and deactivating Developer mode.

0

make sure give permission

sudo chmod 777 . -R

after that

php bin/magento deploy:mode:set developer

otherwise permission denied

0

You Can Do it Using Just simple thing in Your Magento 2 Root Directory

Run this line of code in CLI to delete the content of the Generated Code and Generated Meta Data Directories.

1.$rm –rf <magento_root>/ generated/metadata/* <magento_root>/generated/code/

or can remove directly from your magento2 root directory after that run below cli command in your magento 2 root directory

2.php bin/magento deploy:mode:set developer   ---For Windows

2.$ bin/magento deploy:mode:set developer   ---For Linux
0

As per DEVDOCS here is the solution for you.

If you are changing from Production Mode to Developer Mode you have to clear all generated classes and Objects.

Run this line of code in CLI to delete the content of the Generated Code and Generated Meta Data Directories.

rm –rf <magento_root>/generated/metadata/* <magento_root>/generated/code/*

To set the Mode-

bin/magento deploy:mode:set developer

After running this command it will display a message about Enables Developer Mode

Your Answer

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

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