Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows separator fix on Magento 2.3 #19480

Closed
vincent-bosche opened this issue Nov 30, 2018 · 12 comments

Comments

Projects
None yet
9 participants
@vincent-bosche
Copy link

commented Nov 30, 2018

Preconditions (*)

  1. Magento 2.3.0 (fresh installation from composer)
  2. Windows only

Steps to reproduce (*)

  1. Open any URL in frontend or backend

Expected result (*)

  1. The correct output

Actual result (*)

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: '[..]/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml' in module: '' block's name: 'require.js'
#0 [..]\vendor\magento\framework\View\Element\Template.php(301): Magento\Framework\View\Element\Template->fetchView('C:/www/cardio_t...')
#1 [..]\vendor\magento\framework\View\Element\AbstractBlock.php(668): Magento\Framework\View\Element\Template->_toHtml()
#2 [..]\vendor\magento\framework\View\Result\Page.php(249): Magento\Framework\View\Element\AbstractBlock->toHtml()
#3 [..]\vendor\magento\framework\View\Result\Layout.php(171): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#4 [..]\vendor\magento\framework\Interception\Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#5 [..]\vendor\magento\framework\Interception\Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', Array)
#6 [..]\vendor\magento\framework\Interception\Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#7 [..]\generated\code\Magento\Framework\View\Result\Page\Interceptor.php(39): Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', Array, Array)
#8 [..]\vendor\magento\framework\App\Http.php(139): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#9 [..]\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()
#10 [..]\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#11 {main}
  1. Magento\Framework\View\Element\Template\File\Validator function isPathInDirectories: Windows uses "\" as separator, the array "directories" contains entries with "/" as separator, so the check will always fail.
    $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path)); could be a solution.
@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

commented Nov 30, 2018

Hi @vincent-bosche. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@vincent-bosche do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no
@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

commented Nov 30, 2018

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-backlog-nazar

This comment has been minimized.

Copy link
Contributor

commented Nov 30, 2018

HI @vincent-bosche

Magento 2.3.x technology stack requirements
Operating systems (Linux x86-64)
Linux distributions, such as RedHat Enterprise Linux (RHEL), CentOS, Ubuntu, Debian, and similar.

https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html

@gfxguru

This comment has been minimized.

Copy link

commented Dec 1, 2018

I've run Magento on Windows servers for years without any issues. The fix for me was replacing
$realPath = $this->fileDriver->getRealPath($path);
with
$realPath = str_replace('\', '/', $this->fileDriver->getRealPath($path));

@PathToLife

This comment has been minimized.

Copy link

commented Dec 3, 2018

Can reproduce, fresh install of magento 2.3 on development wamp server is totally borked.

PLEASE INSTALL NEW RELEASES ON WINDOWS AT LEAST ONCE =P

[2018-12-03 17:45:20] main.CRITICAL: Invalid template file: 'C:/wamp64/www/magento/vendor/magento/module-backend/view/adminhtml/templates/admin/login.phtml' in module: 'Magento_Backend' block's name: 'admin.login' [] []

gfguru thanks for the fix!
in: www\vendor\magento\framework\View\Element\Template\File\Validator.php

I've run Magento on Windows servers for years without any issues. The fix for me was replacing
$realPath = $this->fileDriver->getRealPath($path);
with
$realPath = str_replace('', '/', $this->fileDriver->getRealPath($path));

@Jeeva-Rathinam

This comment has been minimized.

Copy link

commented Dec 13, 2018

@vincent-bosche Did you solve in windows platform?

@saktib

This comment has been minimized.

Copy link

commented Dec 19, 2018

For Windows, this is the workaround for now, modify this below file {Magento_Dir}\vendor\magento\framework\View\Element\Template\File\Validator.php

Comment the existing $realpath around line 138 and add the new $realPath

//$realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
@Jeeva-Rathinam

This comment has been minimized.

Copy link

commented Dec 21, 2018

@saktib Still getting same error after update $realPath = str_replace('\', '/', $this->fileDriver->getRealPath($path));
Anything else shall i need to focus?

@saktib

This comment has been minimized.

Copy link

commented Dec 21, 2018

@Jeeva-Rathinam
From your comment I can see you are missing one backslash, it should be like below.
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

@amustci065

This comment has been minimized.

Copy link

commented Dec 28, 2018

@saktib Still getting same error after update $realPath = str_replace('', '/', $this->fileDriver->getRealPath($path));
Anything else shall i need to focus?
Try this $realPath = str_replace('\', '/', $this->fileDriver->getRealPath($path));

@PathToLife

This comment has been minimized.

Copy link

commented Dec 28, 2018

I think you're going down the wrong path installing with windows. Waste of time with M2.3. The routing and build system is bound to have other errors that will keep popping up.

@Jonathonbyrd

This comment has been minimized.

Copy link

commented May 3, 2019

I'm on Ubuntu 18 and I'm still getting this issue. The proposed fix did not fix the problem for me. Telling the customer to use a different operating system is not the kind of support that Magento would allow Extension developers to get away with.

A solution that did work for me was to specify a Theme for the website. Upon installation this seems to have been lost and the db was giving a blank string for the theme name.

elevinskii added a commit to elevinskii/magento2-windows-compatibility that referenced this issue Jul 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.