[Bug?]: After using a symbolic link to move the global cache folder to another partition, "yarn dlx" failed.
Self-service
- [ ] I'd be willing to implement a fix
Describe the bug
Microsoft provides a Dev Drive feature in Windows, and they recommend storing package cache, source code, and other content in this drive. I couldn't find the place to set up the global cache folder, so I used symbolic links to move Yarn's cache folder to this partition. This usually works well, but when I use the yarn dlx command, it creates a temporary project in the% TEMP% folder and then fails due to cross partition linking, like this:
[Error: EXDEV: cross-device link not permitted, link 'C:\Users\<UserName>\AppData\Local\Yarn\Berry\index\bb\*.dat' -> 'C:\Users\<UserName>\AppData\Local\Temp\xfs-5633e527\dlx-15420\node_modules\.store\*\package\LICENSE']
To reproduce
Move Yarn's global cache folder to another partition. Create a symbolic link pointing to a new global cache folder location. Using the yarn dlx command.
Environment
System:
OS: Windows 11 10.0.26120
CPU: (8) x64 AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
Binaries:
Node: 20.11.1 - C:\Users\<UserName>\AppData\Local\Temp\xfs-6fb8e9e9\node.CMD
Yarn: 4.1.1 - C:\Users\<UserName>\AppData\Local\Temp\xfs-6fb8e9e9\yarn.CMD
npm: 10.2.4 - D:\Program Files\nodejs\npm.CMD
---
# I noticed that the path recognized by envinfo seems to be inaccurate. Here is the actual entry file when I execute the command.
PS>@('node','yarn','npm')|%{gcm $_}
CommandType Name Version Source
----------- ---- ------- ------
Application node.exe 20.11.1.0 D:\Program Files\nodejs\node.exe
ExternalScript yarn.ps1 D:\Program Files\nodejs\yarn.ps1
Application npm.cmd 0.0.0.0 D:\Program Files\nodejs\npm.cmd
Additional context
yarn dlx -q envinfo --preset jest
โค YN0001: โ Error: EXDEV: cross-device link not permitted, link 'C:\Users\<UserName>\AppData\Local\Yarn\Berry\index\bc\bc5e9c3195095194973fd9732cedd94d4aad5a6d.dat' -> 'C:\Users\<UserName>\AppData\Local\Temp\xfs-16c48bd1\dlx-18596\node_modules\.store\envinfo-npm-7.14.0-624fecc5a5\package\LICENSE'
โค YN0000: ยท Failed with errors in 1s 291ms
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: EXDEV: cross-device link not permitted, link 'C:\Users\<UserName>\AppData\Local\Yarn\Berry\index\bc\bc5e9c3195095194973fd9732cedd94d4aad5a6d.dat' -> 'C:\Users\<UserName>\AppData\Local\Temp\xfs-16c48bd1\dlx-18596\node_modules\.store\envinfo-npm-7.14.0-624fecc5a5\package\LICENSE'] {
errno: -4037,
code: 'EXDEV',
syscall: 'link',
path: 'C:\\Users\\Shimakaze\\AppData\\Local\\Yarn\\Berry\\index\\bc\\bc5e9c3195095194973fd9732cedd94d4aad5a6d.dat',
dest: 'C:\\Users\\SHIMAK~1\\AppData\\Local\\Temp\\xfs-16c48bd1\\dlx-18596\\node_modules\\.store\\envinfo-npm-7.14.0-624fecc5a5\\package\\LICENSE'
}
Node.js v20.11.1
Looks like you have globally set nodeLinker: pnpm? If so this is one of the limitations of the pnpm linker: your globalFolder and the project (in this case, the temporary folder) must be on the same drive because the pnpm linker needs to create hardlinks between those.
Hi! ๐
It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it.