New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Certain files aren't hardlinked on Windows, and are duplicated instead. #7046
Comments
If creating a hard link fails then pnpm creates a copy: pnpm/fs/indexed-pkg-importer/src/index.ts Lines 136 to 148 in b548f2f
|
Thanks, good to know. So I guess the next question is that why is this consistently failing? I've tried the following, with consistent results:
Anything else I can do to help here? I'm not particularly familiar with this ecosystem so I'm unsure how to proceed. |
After looking at it a bit more, I don't think the copy is being created because something is going wrong with the creation of the hardlink. Rather, I believe that the |
That's actually true. Maybe we can figure out some solution to deduplicate build packages but this was done like this intentionally. There was an issue with built projects linked from the store. For instance, some packages are published with an empty file and then the build script write to the empty file. So when we were hard linking that empty file from the store, it was rewritten for all packages with an empty file. We can't allow any modifications to happen to files in the store. The good news is that pnpm uses side-effects cache, so next time you install the package, it will not be built, so it should be hard linked from the store. But even after building the package we should be able to relink it to the store (though might make no sense from performance perspective). |
Thanks, that makes a lot of sense.
Is there something I have to do to get the side-effects-cache to function like this? With the package in my reproduction above, no matter how many times I install the package I never get a hardlink to the store version - always a copy. The following reproduction will demonstrate this (on my Windows machine at least): git clone https://github.com/MatthewKing/pnpm-issue-7046-reproduction repo1
git clone https://github.com/MatthewKing/pnpm-issue-7046-reproduction repo2
cd .\repo1
pnpm install
.\reproduce.ps1
cd ..\repo2
pnpm install
.\reproduce.ps1 (Both runs of reproduce.ps1 script show that the file is copied not hardlinked, and that the file in the store has no hardlinks elsewhere). Am I misunderstanding how things should work, or is there another area I can investigate and/or help with? Thanks again for your time on this issue. Cheers |
No, there's nothing you should do. It should work by default. As you can see in the code below: pnpm/store/create-cafs-store/src/index.ts Line 37 in e074922
A package is copied only if it requires a build and it is not built. So in theory it should work. I think it is also covered with tests (I hope so). If it doesn't work for you, we should debug it. |
Yeah, it still doesn't work for me (on two machines, reproduced as per the git repo above). Not sure if this helps, but I've noticed that, for the packages it doesn't work on:
|
have deleted my last comment, as I have done more testing since then, and discovered the bug is due to a cobination of two changes:
and
manually editing the pnpm-lock.yaml to include
Results in the file being hardlinked correctly |
Verify latest release
pnpm version
No response
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
https://github.com/MatthewKing/pnpm-issue-7046-reproduction
Reproduction steps
There are full step-by-step instructions in the following repository: https://github.com/MatthewKing/pnpm-issue-7046-reproduction
There is also a script that reproduces the issue (
reproduce.ps1
)A quick summary, though:
Describe the Bug
When using pnpm on Windows 11, some files that I would expect to be hardlinked are not hardlinked. It appears that they are simply copied, leading to duplication. In particular, files such as next-swc.win32-x64-msvc.node are quite large (110mb), and are being duplicated rather than hardlinked. This means that I'm not getting the full benefit of the content addressable store.
Expected Behavior
I would expect that these files are hardlinked, rather than duplicated.
Which Node.js version are you using?
18.16.0
Which operating systems have you used?
If your OS is a Linux based, which one it is? (Include the version if relevant)
No response
The text was updated successfully, but these errors were encountered: