berry icon indicating copy to clipboard operation
berry copied to clipboard

[Question] `EXDEV: cross-device link not permitted` error even when `enableGlobalCache: false`

Open uhyo opened this issue 9 months ago β€’ 3 comments

Hello, sorry for yet another cross-device link not permitted issue. However, please view this issue as rather a question.

First, here's the error we're seeing on our CI environment (with some internal stuff masked):

[Error: EXDEV: cross-device link not permitted, link '/root/.yarn/berry/index/bf/bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f.dat' -> '/*****/node_modules/.store/*****/package/.prettierrc'] {
  errno: -18,
  code: 'EXDEV',
  syscall: 'link',
  path: '/root/.yarn/berry/index/bf/bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f.dat',
  dest: '/*****/node_modules/.store/*****/package/.prettierrc'
}

(where the link source looks like in the global cache and the dest is inside our project folder)

Looking at #6457 and other issues, I wanted to try disabling the global cache. Here's my .yarnrc.yml:

# .yarnrc.yml
nodeLinker: pnpm
yarnPath: .yarn/releases/yarn-4.6.0.cjs
enableGlobalCache: false
enableMirror: false

However, the exactly same error still happens. I thought these settings would totally disable use of the global cache, including the hard-linking behavior.

Question: is there a way to completely disable hard-linking from the global cache?

Thank you!

uhyo avatar Feb 18 '25 10:02 uhyo

The pnpm linker, by definition, needs to hardlink to a global content-addressable store.

If you don't want that, you probably just want to use the node-modules linker. Or is there something you need the pnpm linker for that can't be done with the node-modules linker

clemyan avatar Mar 14 '25 19:03 clemyan

Thank you for response!

First of all, we want to disable the hardlinking from the global store only when yarn is running on CI. Actually, we want to disable the hardlinking by an environment variable (YARN_ENABLE_GLOBAL_CACHE) rather than .yarnrc.yml.

The reason why we stick to the pnpm linker is that it has stricter hoisting behavior. Also, the pnpm linker is more storage-efficient (at least in our case).

At first I thought that by disabling the global.cache the pnpm linker would switch to hard- (or maybe sym-) linking from a β€œlocal” store (.yarn/cache), but it wasn't the case.

Currently, our workaround for the cross-device link error is to override the global store path to somewhere local.

uhyo avatar Mar 17 '25 10:03 uhyo

Maybe also just allowing the use of symlinks instead of hardlinks would help, they can go across filesystems and should work for 99.9% of use cases, but I currently see no option to use them instead of hardlinks. The pnpm mode itself works great, it just should maybe be an option to switch to symlinks.

megla-tlanghorst avatar Nov 28 '25 17:11 megla-tlanghorst