magento-hackathon / magento-composer-installer

Composer installer for Magento modules
210 stars 154 forks source link

Issue with long symlinks on Windows #142

Closed HenningCash closed 9 years ago

HenningCash commented 9 years ago

We ran into some weird problems on our Windows development machines when using symlinks as deploy-strategy. For some reasons PHP refuses to include the symlinked file when it has a relative path that is quite long. The file can be opened without problems in explorer-context.
This causes the mg Autoloader to fail and classes can't be loaded. A simple test file that tries to include the symlink fails aswell.

Source:
D:\www\mg.testenvironment\vendor\connect20\DerModPro_BasePrice\app\code\community\DerModPro\BasePrice\Model\Entity\Resource\Eav\Attribute\Product\Amount.php

Symlink (as output from cmd dir):
..\..\..\..\..\..\..\..\..\..\..\..\vendor\connect20\DerModPro_BasePrice\app\code\community\DerModPro\BasePrice\Model\Entity\Resource\Eav\Attribute\Product\Amount.php

The resulting path is longer than 260 chars, which is by default the maximum path-length windows can handle. But I can only guess that this is the reason. The depths of magento's paths give a quite high change hitting this limit.

When you change the symlink to an absolute path - manually in cmd or hacking in Symlink.php+redeploy - the include/Autoloader works fine but this would drop some flexibility.

davidverholen commented 9 years ago

I want to say "dont use Windows" ;), but that would be unprofessional ...

there was an issue, why the Installer did avoid making relative symlinks on Windows, but since #132 it seemed to not break deployment anymore.

Maybe it still does

HenningCash commented 9 years ago

The developer in me is no Windows fan either..

I can try to provide a PR that checks the path-length of a symlink before creating it and makes it absolute. There should also be a warning during the deployment process if such a link is detected, but seems like Deploystrategies have no access to console-output?

davidverholen commented 9 years ago

right, so far. You could inject the io Object into the Strategy in the Installer where the DeployStrategies are instantiated

Flyingmana commented 9 years ago

after reading a bit trough http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath I would suggest, we disable the relative symlink option for windows, as absolute paths dont have this problem, or at least their limit could get extended to much higher