-
-
Notifications
You must be signed in to change notification settings - Fork 107
Description
By default, shards place a symlink lib into each installed dependency's directory, which points back to the top-level lib directory.
The target directory is a parent of the link, which causes a recursive loop.
For example, in this repository:
$ ls -l -d lib/molinillo/lib
lrwxrwxrwx - johannes 8 May 22:47 lib/molinillo/lib -> ..So lib/molinillo/lib is identical to lib. This means ridiculously nested paths such as lib/molinillo/lib/molinillo/lib/molinillo/lib/molinillo/lib resolve.
Recursive symlinks are technically valid. But they can cause problems. I understand it's generally recommended to avoid them.
A practically relevant problem is that Git for Windows seems to turn symlinks into hard copies, which won't work for recursive symlinks (ref. crystal-lang/crystal#6170 (comment)). So currently it's not possible to check out repositories with a vendored lib directory on Windows. config.symlinks=false only creates text files instead of actual symlinks and config.symlinks=true refuses to create recursive symlinks.
But there are other concerns as well, for example any kinds of tooling can have issues with recursive symlinks. Tools that are unaware of symlink loops could end up in infinite recursion, for example.
I think it would be best to avoid symlink recursion in shards.
An obvious solution would be to drop those nested lib directory and require to always use the root directories lib folder directly. But this is not convenient and would likely break existing workflows.
Another option would require compiler support for text-file based symlinks. When the compiler requires a file and any of its parent paths is not a directory but a text file containing a valid path, it would replace the parent path with the file content. Homemade symlink resolution.
This would not work for other tooling that's unrelated to Crystal. But it's reasonable to assume the lib symlink is primarily intended for the Crystal compiler and potentially related tooling which could be aware of this special treatment.
As a bonus effect, this would implicitly enable the compiler to support git checkouts with config.symlinks=false and thus support platforms where symlinks are not available.
Metadata
Metadata
Assignees
Type
Projects
Status