ddev: ddev composer still doesn't quite do symlinks that result in proper behavior
Describe the bug
In v1.4.0 we introduced ddev composer
, whose intent is to provide in-container predictable behavior, especially on Windows.
Inside the linux containers, creating a symlink appears to work (ln -s), and most linux commands respect it.
Sadly, php does not respect the “XSym” file that is created. So if you try to read a symlink with PHP, you’ll get the contents of the XSym file, not the contents of the target file.
To Reproduce
- On Windows, in the container, on the mounted NTFS volume, create a file named README.md with the contents
This is just a simple readme for testing purposes.
- create a symlink to the README.md. For example,
ln -s README.md mysymlink.md
- Read the file with cat. It will work fine.
cat mysymlink.md
will result in the proper output (the content of README.md). - Read the file with PHP instead, using this script:
<?php
if ($fh = fopen('mysymlink.md', 'r')) {
while (!feof($fh)) {
$line = fgets($fh);
echo $line;
}
fclose($fh);
}
Expected behavior
php should read the target file instead. Which is what it does if you create a proper symlink on the Windows host:
- Developer mode must be turned on on the host (See https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/)
- In git-bash
export MSYS=winsymlinks:nativestrict
- ln -s README.md mysymlink.md
- Read the file with the same php script inside the container. It gets the correct content.
Additional context
- @ohader notes that this project creates unusable symlinks even when run inside the container: https://github.com/HofUniversityIndieOne2018/red-cross-project
- @ohader has also written a script (to be run on the host, after composer install, https://gist.github.com/ohader/f4b792e0bb99e79efe75605008ce4a0d#file-use-native-symlinks-sh, to relink XSym as “junction symlinks”
- This old forum post gives some context about “junction links”
- This docker-for-win issue seems to deal with the same problems: https://github.com/docker/for-win/issues/137
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 16 (10 by maintainers)
Thanks for taking it for a spin! Hopefully it will work out for people. It’s possible that in the future we’ll want to make a command that does nothing but “repair” XSym links.