Skip to content
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

ERR_PNPM_LINKING_FAILED when running pnpm install in Docker on macOS #7024

Open
4 tasks done
binaryfire opened this issue Sep 1, 2023 · 22 comments
Open
4 tasks done

Comments

@binaryfire
Copy link

binaryfire commented Sep 1, 2023

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

v8.7.1

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

  1. Create a Node-based image which includes PNPM
  2. On macOS, bind mount a project to it and attempt to run pnpm install a couple of times inside the container

Describe the Bug

This article describes the same bug I'm experiencing: https://zenn.dev/minedia/articles/2023-08-30-pnpm#%E4%BD%99%E8%AB%87%3A-pnpm%E3%81%AE%E3%82%A8%E3%83%A9%E3%83%BC

Translated:
image

Basically, it seems like the hard links PNPM uses don't work properly under Docker for macOS.

Expected Behavior

PNPM should work the same way in Docker containers on macOS as it does on Linux and Windows WSL2

Which Node.js version are you using?

18.17.1

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

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

macOS 12

@binaryfire binaryfire changed the title ERR_PNPM_LINKING_FAILED when running pnpm install in Docker on macOS ERR_PNPM_LINKING_FAILED when running pnpm install in Docker on macOS Sep 1, 2023
@binaryfire
Copy link
Author

Another thread explaining the same issue: https://twitter.com/david_negrier/status/1608012478851743744?s=20

@weyert
Copy link
Contributor

weyert commented Sep 4, 2023

Looks like a duplicate of #5803 or at least related

@Joshuajrodrigues
Copy link

Im facing same issue but on windows...

@dotoleeoak
Copy link

I added this line in .npmrc file and it works like charm!

package-import-method=clone-or-copy

@AIABHISHEK
Copy link

same error occured on windows I just updated the pnpm package and it worked .
pnpm -v 8.8.0

@can-acar
Copy link

can-acar commented Oct 5, 2023

The issue still persists in Windows.
Node 18.18.0
pnpm version 8.8.0

@meister245
Copy link

meister245 commented Oct 13, 2023

The way I resolved this issue is the following:

I added a postCreateCommand to my devcontainer.json

"postCreateCommand": "bash .devcontainer/post-create.sh",

In the post create script I set the pnpm store to a folder in the user home:
pnpm config set store-dir /home/vscode/.pnpm-store

I then added a mount in the devcontainer.json file, to mount my host pnpm store folder in the container:

"mounts": [
    "type=bind,source=/Users/${localEnv:USER}/Library/pnpm/store,target=/home/vscode/.pnpm-store"
]

since then pnpm install works without an issue.

@binaryartifex
Copy link

binaryartifex commented Oct 18, 2023

still persisting in windows. For some reason the cypress path is the only one that triggers this bloody error.

Error: EPERM: operation not permitted, rename 'F:\[...path]\node_modules\.pnpm\cypress@13.3.2\node_modules\cypress_tmp_27736' -> 'F:\[...path]\node_modules\.pnpm\cypress@13.3.2\node_modules\cypress'

@hanyaonian
Copy link

hanyaonian commented Oct 20, 2023

still persisting in windows. For some reason the cypress path is the only one that triggers this bloody error.

Error: EPERM: operation not permitted, rename 'F:\[...path]\node_modules\.pnpm\cypress@13.3.2\node_modules\cypress_tmp_27736' -> 'F:\[...path]\node_modules\.pnpm\cypress@13.3.2\node_modules\cypress'

Same here Q-Q
Every time I had this issue, I have to restart my computer (and then it works well).
I am using pnpm version 8.9.2 and Windows 10

@darkbasic
Copy link

Same issue on Arch Linux. I'm not using containers.

@artemgordash
Copy link

I added this line in .npmrc file and it works like charm!

package-import-method=clone-or-copy

with this works, thank you

@danielrotaermel
Copy link

Same issue on multiple windows machines (no docker involved). Tried pnpm 8.8.0 8.7.0 8.10.0 (installed via npm i -g pnpm). Always getting an ERR_PNPM_LINKING_FAILED Error: EPERM: operation not permitted, rename <some random package>

@danielrotaermel
Copy link

danielrotaermel commented Oct 30, 2023

It seems like running Antivirus software could be the culprit npm/npm#10826 npm/npm#14027

Unfortunately this does not fix it npm/npm#10826 (comment)

@ickers
Copy link

ickers commented Nov 1, 2023

FWIW, npm/npm#10826 (comment) was the clue that got me past this after much thrashing @danielrotaermel (again, windows and no docker) - closed VS Code and suddenly everything worked like a charm.

@danielrotaermel
Copy link

danielrotaermel commented Nov 11, 2023

Found a way around the file locking by the anti virus software. Rerunning pnpm
install until antivirus is done checking the files. Note: after some experimentation that I found that hoisting via copy does not work -> symlinks work.

Maybe there is a way to increase the timeout for retries or at least log whats causing the file lock or something?

@darkbasic
Copy link

darkbasic commented Nov 23, 2023

package-import-method=clone-or-copy

That doesn't work on Linux + zfs (no containers).
No other application is using the project folder.

@jdnavarro
Copy link

There is copy-clone bug in ZFS that may be related.

In my case, setting package-import-method=hardlink fixes the issue.

@mtymek
Copy link

mtymek commented Dec 5, 2023

I encountered the same issue today, and cleaning node_modules or pnpm prune did not help.
Switching the "file sharing implementation" (in Docker settings) from VirtioFS to gRPC FUSE has resolved it.

image

@rflihxyz
Copy link

rflihxyz commented Jan 21, 2024

Hey, I had the same issue and managed to get this fixed in my repo

https://github.com/panoratech/Panora

The solution was to add a line "node-linker=hoisted" to the .npmrc file

read more here: https://pnpm.io/npmrc#node-linker

Edit: the fix is not working for everyone

@gyunseo
Copy link

gyunseo commented Feb 5, 2024

package-import-method=clone-or-copy

@dotoleeoak thanks! that workaround works!!!

@rocketjsquirrel
Copy link

Edit: the fix is not working for everyone

It worked for me on my intel mac, but not my co-worker with an apple processor based mac.
I added both entries:

package-import-method=clone-or-copy
node-linker=hoisted 

and it works for both of us.

@cristian-cll
Copy link

cristian-cll commented Mar 11, 2024

I too tried to switch from VirtioFS to gRPC FUSE and was able to run the command without problems. But I noticed that it lowered the I/O efficiency of the containers.
However, when I put in the .npmrc

package-import-method=clone-or-copy

All correct and with VirtioFS.
Thanks!

nicholeuf added a commit to nicholeuf/udemy-sleepr that referenced this issue Mar 29, 2024
nicholeuf added a commit to nicholeuf/udemy-sleepr that referenced this issue Mar 29, 2024
* set the package-import-method=hardlink

pnpm/pnpm#7024 (comment)

* commit recreated pnpm-lock files generated from calling `pnpm i -r` on the command line

* remove -r flag in the docker files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests