pnpm / pnpm

Fast, disk space efficient package manager
https://pnpm.io
MIT License
29.7k stars 1.01k forks source link

Hard link does not take effect #7800

Closed rainwind132 closed 7 months ago

rainwind132 commented 7 months ago

Verify latest release

pnpm version

8.15.4

Which area(s) of pnpm are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

Verify whether packages installing the same version in different projects are hard links

  1. Create two folders test1 test2
  2. Initialize pnpm init
  3. Install in each folder: pnpm install react
  4. Enter cd node_modules/.pnpm/react@18.2.0/node_modules/react/umd
  5. ls -li
  6. 对比react.production.min.js | react.development.js | react.profiling.min.js文件 的inode
  7. test1 和test2中的React文件inode是不同的

image image

Describe the Bug

Hard link failed

Hard links installed in different projects for the same version of dependencies are invalid. Is there something wrong with my understanding?

My node 20.0.0 npm 9.6.4

MacBook pro Chip M2 System Ventura 13.2.1

Expected Behavior

The inode of the file should be the same

Which Node.js version are you using?

20.0.0

Which operating systems have you used?

If your OS is a Linux based, which one it is? (Include the version if relevant)

Ventura

zkochan commented 7 months ago

On disks that support copy-on-write, pnpm uses reflinks instead of hard links. reflinks will not have the same inodes even though they point to the same physical data blocks. reflinks are faster than hard links on macOS and use the same amount of disk space.

If you want hard links instead, you can set the package-import-method=hardlink setting.