Magento2 Error – Failed to Open Stream: No Such File or Directory

magento2

I ran the setup:upgrade command and I'm getting the following error when I open my website

Warning: include(/var/www/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory

I thought this was a permissions issue but I ran chown on the entire magento folder recursively and this seems to do nothing. There are no files in the view_preprocessed folder even after running setup:upgrade and setup:di:compile so I believe that is the issue but I don't know how to solve it

Best Answer

Try running followings in given order.

php bin/magento setup:upgrade
rm -rf var/{cache,di,generation,page_cache,view_preprocessed}
php bin/magento setup:static-content:deploy
php bin/magento setup:di:compile

--- Update ---

Your module should be working. You can check it by removing the content area from inside the new module.

Admin: create Vendor/Module/view/adminhtml/layout/default.xml with following content.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceContainer name="content" remove="true"/>
</page>

Clean the cache and refresh the admin section. The main content area should not be visible. Otherwise, you have something wrong with your module. Check all file/folder name. Pay attention to the case.

Related Topic