cancel
Showing results for 
Search instead for 
Did you mean: 

An error has happened during application run. See exception log for details.

Re: An error has happened during application run. See exception log for details.

I used "-f" and problem solved but why Magento couldn't work properly:

Screenshot-5.png

Re: An error has happened during application run. See exception log for details.

hello @jason_long 

 

you are running all command using sudo,so when you run command ther permission issue occurs.

 

so every time run command you need to give permission

chmod 0777 -R generation var/


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: An error has happened during application run. See exception log for details.

@jason_long 
Generally for the following command we don't need to add -f in developer mode.

php bin/magento setup:static-content:deploy

or 

php bin/magento setup:static-content:deploy -f

But sometime on the server we need to add -f with the command. -f stand for forcefully. 

Re: An error has happened during application run. See exception log for details.

I did but problem exist!!!!

I tested without "sudo" but problem not solved.

I changed permission for "html" directory:

$ ll
total 1216
drwxrwxrwx.  4 magento apache   4096 May 19 13:47 app
-rwxrwxrwx.  1 magento apache    234 Mar 15 09:42 auth.json.sample
drwxrwxrwx.  2 magento apache     36 May 21 11:36 bin
-rwxrwxrwx.  1 magento apache 434981 Mar 15 09:42 CHANGELOG.md
-rwxrwxrwx.  1 magento apache   2257 Mar 15 09:38 composer.json
-rwxrwxrwx.  1 magento apache 714229 Mar 15 09:42 composer.lock
-rwxrwxrwx.  1 magento apache    650 Mar 15 09:42 COPYING.txt
drwxrwxrwx.  5 magento apache     59 May 19 13:47 dev
drwxrwxrwx.  4 magento apache     48 May 21 16:11 generated
-rwxrwxrwx.  1 magento apache     57 Mar 15 09:42 grunt-config.json.sample
-rwxrwxrwx.  1 magento apache   2994 Mar 15 09:42 Gruntfile.js.sample
-rwxrwxrwx.  1 magento apache   1435 May 21 13:02 index.php
drwxrwxrwx.  4 magento apache     47 May 19 13:47 lib
-rwxrwxrwx.  1 magento apache  10376 Mar 15 09:42 LICENSE_AFL.txt
-rwxrwxrwx.  1 magento apache  10364 Mar 15 09:42 LICENSE.txt
-rwxrwxrwx.  1 magento apache   5625 Mar 15 09:42 nginx.conf.sample
-rwxrwxrwx.  1 magento apache   1416 Mar 15 09:42 package.json.sample
-rwxrwxrwx.  1 root    root       68 May 20 10:55 phpinfo.php
drwxrwxrwx.  2 magento apache     55 May 19 13:47 phpserver
drwxrwxrwx.  6 magento apache   4096 May 19 13:47 pub
drwxrwxrwx.  7 magento apache   4096 May 19 13:47 setup
drwxrwxrwx.  7 magento apache   4096 May 19 13:47 update
drwxrwsrwx.  9 magento apache   4096 May 21 16:11 var
drwxrwsrwx. 76 magento apache   4096 May 19 13:47 vendor

And did commands without "sudo":

$ php -d memory_limit=4G bin/magento setup:di:compile
Compilation was started.
Interception cache generation... 7/7 [============================] 100% 35 secs 329.0 MiB
Generated code and dependency injection configuration successfully.

$ php -d memory_limit=4G bin/magento setup:static-content:deploy -f

Deploy using quick strategy
frontend/Magento/blank/en_US            2245/2245           ============================ 100% %  7 secs              
adminhtml/Magento/backend/en_US         2328/2328           ============================ 100% %  7 secs              
frontend/Magento/luma/en_US             2260/2260           ============================ 100% %  8 secs

Execution time: 39.555767059326

$ php -d memory_limit=4G bin/magento indexer:reindex
Design Config Grid index has been rebuilt successfully in 00:00:00
Customer Grid index has been rebuilt successfully in 00:00:00
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:00
Inventory index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Stock index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:00


$ php -d memory_limit=4G bin/magento cache:flush
Flushed cache types:
config
layout
block_html
collections
reflection
db_ddl
compiled_config
eav
customer_notification
config_integration
config_integration_api
full_page
config_webservice
translate
vertex

Logs are:

$ tail var/log/debug.log 
[2019-05-21 11:43:07] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_1"}} []
[2019-05-21 11:43:07] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_2"}} []
[2019-05-21 11:43:07] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_3"}} []
[2019-05-21 11:43:07] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_4"}} []
[2019-05-21 11:43:07] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_1"}} []
[2019-05-21 11:43:07] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_2"}} []
[2019-05-21 11:43:07] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_3"}} []
[2019-05-21 11:43:07] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_4"}} []
[2019-05-21 11:43:31] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"tags":["FPC"],"mode":"matchingTag"}} []
[2019-05-21 11:43:54] main.DEBUG: cache_invalidate: {"method":"GET","url":"http://172.20.100.64/","invalidateInfo":{"identifier":"SYSTEM_CONFIG"}} []

And:

$ tail var/log/exception.log 
Class Magento\\Framework\\App\\Http\\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. at /var/www/html/vendor/magento/framework/Code/Generator.php:135)"} []
[2019-05-21 08:14:09] main.CRITICAL: The specified "/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29733" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29733): failed to open stream: Permission denied
Class Magento\Framework\App\Http\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. {"exception":"[object] (RuntimeException(code: 0): The specified \"/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29733\" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29733): failed to open stream: Permission denied
Class Magento\\Framework\\App\\Http\\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. at /var/www/html/vendor/magento/framework/Code/Generator.php:135)"} []
[2019-05-21 08:16:32] main.CRITICAL: The specified "/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29735" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29735): failed to open stream: Permission denied
Class Magento\Framework\App\Http\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. {"exception":"[object] (RuntimeException(code: 0): The specified \"/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29735\" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29735): failed to open stream: Permission denied
Class Magento\\Framework\\App\\Http\\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. at /var/www/html/vendor/magento/framework/Code/Generator.php:135)"} []
[2019-05-21 08:20:39] main.CRITICAL: The specified "/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29731" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29731): failed to open stream: Permission denied
Class Magento\Framework\App\Http\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. {"exception":"[object] (RuntimeException(code: 0): The specified \"/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29731\" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29731): failed to open stream: Permission denied
Class Magento\\Framework\\App\\Http\\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. at /var/www/html/vendor/magento/framework/Code/Generator.php:135)"} []

And:

$ tail var/log/system.log 
[2019-05-21 08:11:07] main.CRITICAL: The specified "/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29732" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29732): failed to open stream: Permission denied
Class Magento\Framework\App\Http\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. [] []
[2019-05-21 08:14:09] main.CRITICAL: The specified "/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29733" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29733): failed to open stream: Permission denied
Class Magento\Framework\App\Http\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. [] []
[2019-05-21 08:16:32] main.CRITICAL: The specified "/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29735" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29735): failed to open stream: Permission denied
Class Magento\Framework\App\Http\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. [] []
[2019-05-21 08:20:39] main.CRITICAL: The specified "/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29731" file couldn't be written. Warning!file_put_contents(/var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php.29731): failed to open stream: Permission denied
Class Magento\Framework\App\Http\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. [] []
[2019-05-21 11:31:39] main.CRITICAL: Can't create directory /var/www/html/generated/code/Magento/Framework/App/ResourceConnection/.
Class Magento\Framework\App\ResourceConnection\Proxy generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. [] []

 

Re: An error has happened during application run. See exception log for details.

Nobody know my problem?
Can SELinux cause any problem?

Re: An error has happened during application run. See exception log for details.

Hello @jason_long 

 

please setup permission based on document

https://devdocs.magento.com/guides/v2.3/config-guide/prod/prod_file-sys-perms.html

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: An error has happened during application run. See exception log for details.

In which file I should add above lines?

Re: An error has happened during application run. See exception log for details.

Perfect, thanks - that's got things back up and running after an attempted dodgey template upgrade. 

 

To summarise, the commands essentially cleared down the cache and the ran the Magento setup again? For future reference, if I had a web site content would the commands also clear that out?

 

Also, we've given full permission (0777) permission here, are there any security risks associated with this?

 

Thanks again, 

Dave.