Description
Self-service
- I'd be willing to implement a fix
Describe the bug
I was encountering issues in an Azure Devops build during the "git clean" process. The cause was a few of my workspaces had the hoistingLimits set to "workspaces" to prevent their dependencies messing with the shared ones. Unfortunately those workspaces' node_modules also had a JUNCTION to the parent dir, effectively creating an infinite loop.
The git clean went on for ages before giving up at last.
I discovered that setting "selfReferences": false would solve this.
I wonder, though, if this should have been necessary. In my case anyway, I'd much prefer "selfReferences" to default to false when the hoisting limit is workspaces.
To reproduce
On Windows, create a repo using yarn 3 and one or more workspaces. In one of the workspaces, set the hoisting limit:
"installConfig": {
"hoistingLimits": "workspaces"
},
Run yarn install and inspect the directory structure. The workspace contains a node_modules folder with a JUNCTION back to the parent dir.
Also, initialize a git repo and commit what you have.
Attempt to run git clean. It will likely get stuck on the recursive directory.
If this was a symlink it might not be so bad, but it seems a junction is treated as a true folder, so it just keeps following it until it runs out of memory or something.
Environment
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Binaries:
Node: 18.12.1 - ~\AppData\Local\Temp\xfs-6d6e6317\node.CMD
Yarn: 3.2.1 - ~\AppData\Local\Temp\xfs-6d6e6317\yarn.CMD
npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
Additional context
No response