When i run magento command i get this error.

  Warning: is_file() expects parameter 1 to be a valid path, string given in   
  File.php on line 512

3 Answers 3


Try this :

rm -rf var/cache var/log var/page_cache var/view_preprocessed

More detail : https://github.com/magento/magento2/issues/10878


No need to delete particular folder just run this command :-

Just One time

rm -rf var/view_preprocessed/*   == Clear cache 
rm -rf generated/* == Clear generated classes 

Please do not run

rm -rf var/* 

Because it will removed your database backup and other module log files.

  • For second line, added -r recursive flag since hierarchy of files existed in my case.
    – jiy
    Commented Jul 2, 2019 at 14:00

I solved this problem by deleting content under the var/view_preprocessed/ and generated/ directories. I then ran the commands(in this order):

php bin/magento setup:di:compile

php bin/magento setup:upgrade

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

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.