berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug?]: pnpm linker doesn't deal with case-sensitive name clashes inside packages

Open neongreen opened this issue 2 years ago • 4 comments

Self-service

  • [ ] I'd be willing to implement a fix

Describe the bug

See https://github.com/react-icons/react-icons/issues/888.

A package containing both GiHeadshot.esm.js and GiHeadShot.esm.js breaks Yarn at the linking phase:

[Error: EEXIST: file already exists, link '.../.yarn/berry/index/7e/7ea922d48088082a4ed456fa4891380798f4a8ac.dat' -> '/private/tmp/foo/node_modules/.store/@react-icons-all-files-virtual-50b10d4290/package/gi/GiHeadShot.esm.js'] {
  errno: -17,
  code: 'EEXIST',
  syscall: 'link',
  path: '.../.yarn/berry/index/7e/7ea922d48088082a4ed456fa4891380798f4a8ac.dat',
  dest: '/private/tmp/foo/node_modules/.store/@react-icons-all-files-virtual-50b10d4290/package/gi/GiHeadShot.esm.js'
}

Everything is ok with the pnp linker. Everything was also ok at yarn 3.7.0.

To reproduce

Sherlock not provided because the Sherlock links doesn't work.

mkdir foo && cd foo
yarn init --yes
yarn set version 4.0.2
echo "nodeLinker: pnpm" >> .yarnrc.yml
yarn add @react-icons/[email protected]

Environment

System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 21.5.0 - /private/var/folders/1t/s_4crr9n12j7k7k9_hnxx5hm0000gn/T/xfs-f9dcafbb/node
    Yarn: 4.0.2 - /private/var/folders/1t/s_4crr9n12j7k7k9_hnxx5hm0000gn/T/xfs-f9dcafbb/yarn
    npm: 10.2.4 - ~/.volta/tools/image/node/21.5.0/bin/npm
    pnpm: 7.0.1 - ~/.volta/bin/pnpm
    bun: 1.0.20 - /opt/homebrew/bin/bun

Additional context

No response

neongreen avatar Jan 02 '24 14:01 neongreen

Can be worked around by re-packing the package (and losing conflicting files):

cd overrides
wget "https://github.com/react-icons/react-icons/releases/download/v4.1.0/react-icons-all-files-4.1.0.tgz"
mkdir react-icons
tar xf react-icons-all-files-4.1.0.tgz -C react-icons
rm react-icons-all-files-4.1.0.tgz
tar czf react-icons.tar.gz -C react-icons .
rm -rf react-icons
cd ..

yarn add @react-icons/all-files@./overrides/react-icons.tar.gz

neongreen avatar Jan 02 '24 15:01 neongreen

This isn't a bug. The pnpm linker relies on the filesystem (same as the node_modules one), so its case sensitivity behaviour depends on the filesystem sensitivity. The OSX filesystem is case insensitive, so packages with files relying on insensitivity cannot work.

PnP doesn't have this problem since the content of the zip archives is managed by Yarn itself.

arcanis avatar Jan 02 '24 16:01 arcanis

I don't think Yarn can do anything to actually let me use both a.js and A.js, but it could a) detect the issue, b) offer to use pnp, and c) offer to say "I know what I'm doing, please just overwrite one of the files". Yarn 3.7.0 seems to overwrite the files and so does pnpm.

neongreen avatar Jan 02 '24 16:01 neongreen

I mean, of course there's a strong argument that the package should simply be fixed and it's not Yarn 4's problem.

But I feel like it's somewhat dampened by the fact that all (?) package managers pre Yarn 4, including Yarn 3 with any nodeLinker, will install this package. So it might be a long battle.

neongreen avatar Jan 02 '24 16:01 neongreen