51

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? Commented Jan 14, 2014 at 15:20
  • @Tim I am using Apache. I set it by adding it to the top of the .htaccess Commented Jan 14, 2014 at 15:28
  • Adding what? Please add all this info into your question. Commented 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
    Commented Jan 14, 2014 at 19:04

13 Answers 13

98

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
    Commented 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. Commented Jun 14, 2016 at 10:30
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
    Commented 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.
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 you have read our privacy policy.

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