1

Magento 2.2 When I enable developer mode, the Magento doesnot work and displays this error instead

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Theme layout update file ' public_html/app/design/frontend/Mgs/XXX/Magento_Contact/layout/contact_index_index.xml' is not valid.
XML declaration allowed only at the start of the document
 Line: 2

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Theme layout update file ' public_html/app/design/frontend/Mgs/XXX/Magento_Contact/layout/contact_index_index.xml' is not valid.
XML declaration allowed only at the start of the document
 Line: 2
#0  public_html/vendor/magento/framework/View/Model/Layout/Merge.php(662): Magento\Framework\View\Model\Layout\Merge->_loadFileLayoutUpdatesXml()
#1  public_html/generated/code/Magento/Framework/View/Model/Layout/Merge/Interceptor.php(245): Magento\Framework\View\Model\Layout\Merge->getFileLayoutUpdatesXml()
#2  public_html/vendor/magento/framework/View/Model/Layout/Merge.php(535): Magento\Framework\View\Model\Layout\Merge\Interceptor->getFileLayoutUpdatesXml()
#3  public_html/vendor/magento/framework/View/Model/Layout/Merge.php(514): Magento\Framework\View\Model\Layout\Merge->_fetchPackageLayoutUpdates('default')
#4  public_html/vendor/magento/framework/View/Model/Layout/Merge.php(438): Magento\Framework\View\Model\Layout\Merge->_merge('default')
#5  public_html/generated/code/Magento/Framework/View/Model/Layout/Merge/Interceptor.php(193): Magento\Framework\View\Model\Layout\Merge->load(Array)
#6  public_html/vendor/magento/framework/View/Layout/Builder.php(86): Magento\Framework\View\Model\Layout\Merge\Interceptor->load()
#7  public_html/vendor/magento/framework/View/Layout/Builder.php(63): Magento\Framework\View\Layout\Builder->loadLayoutUpdates()
#8  public_html/vendor/magento/framework/View/Layout.php(254): Magento\Framework\View\Layout\Builder->build()
#9  public_html/vendor/magento/framework/View/Layout.php(875): Magento\Framework\View\Layout->build()
#10  public_html/generated/code/Magento/Framework/View/Layout/Interceptor.php(414): Magento\Framework\View\Layout->getBlock('page_content_he...')
#11  public_html/vendor/magento/module-cms/Helper/Page.php(171): Magento\Framework\View\Layout\Interceptor->getBlock('page_content_he...')
#12  public_html/vendor/magento/module-cms/Controller/Index/Index.php(43): Magento\Cms\Helper\Page->prepareResultPage(Object(Magento\Cms\Controller\Index\Index\Interceptor), 'home')
#13  public_html/generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php(24): Magento\Cms\Controller\Index\Index->execute(NULL)
#14  public_html/vendor/magento/framework/App/Action/Action.php(107): Magento\Cms\Controller\Index\Index\Interceptor->execute()
#15  public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#16  public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cms\Controller\Index\Index\Interceptor->___callParent('dispatch', Array)
#17  public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#18  public_html/generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php(39): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#19  public_html/vendor/magento/framework/App/FrontController.php(55): Magento\Cms\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#20  public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#21  public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#22  public_html/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#23  public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#24  public_html/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#25  public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#26  public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#27  public_html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
#28  public_html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#29  public_html/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http->launch()
#30  public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#31 {main}

contact_index_index.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="page.main.title">
        <action method="setPageTitle">
            <argument translate="true" name="title" xsi:type="string">Contact</argument>
        </action>
    </referenceBlock>
</page>

Cannot switch into given mode "default"

The directory "public_html/generated/code/Magento/Framework" cannot be deleted Warning!rmdir(public_html/generated/code/Magento/Framework): Directory not empty
  • Open contact_index_index.xml and post it here, it looks like it is importly formatted from the error. file is located at app/design/frontend/Mgs/unero/Magento_Contact/layout/contact_index_index.xml. You'll probably find that the XML definition was put on the second line of the file, instead of the first. Or it has been defined twice – Eirik Nov 26 '17 at 19:10
  • @Eirik update <?xml version="1.0"?> <!-- /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <referenceBlock name="page.main.title"> <action method="setPageTitle"> <argument translate="true" name="title" xsi:type="string">Contact</argument> </action> </referenceBlock> </page> – niceonelee Nov 26 '17 at 19:32
  • Update your original post with the contents, we cant read it in its original format when added as a comment. – Eirik Nov 26 '17 at 19:33
  • @Eirik updated ^^" – niceonelee Nov 26 '17 at 19:35
  • 1
    Is there an extra line or spacing before <?xml version="1.0"?> ? It will throw the error you are seeing if there is anything before the opening xml declaration – Eirik Nov 26 '17 at 19:35
1

@rigu Once you change modes from "Default" to either "Developer" or "Production" modes - you CAN NOT revert back to "Default" mode.

Red Pill vs Blue Pill

This StackExchange thread has more information on the topic - Why can't one switch back to the default mode on Magento 2?

There is an open M2x ticket requesting that "feature" be added - but, FWIW, I wouldn't hold my breath - https://github.com/magento/magento2/issues/4292

Hope this helps! :)

0

Try to add referenceBlock tag inside the body tag. Maybe it will help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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