Closed momesana closed 2 months ago
or is that already the fix?
And after a cursory glance at the code I'd assume that the following mode should be 'r'
instead of 'r+'
:
https://github.com/nodejs/corepack/blob/476b7dc3c9c6946ff664734df5c1870eb65cffba/sources/Engine.ts#L146
I've built and used the newest master revision from the corepack repo and replaced the one in the image with that and then it works so I assume the issue has been addressed by "c449adc feat: separate read and write operations on lastKnownGood.json (#446)"
Closed it as it's effectively a duplicate of https://github.com/nodejs/corepack/issues/183
Will this be in node 20? It was merged only 3 days after v20.12.2 was released.
(originally posted as a discussion post here: https://github.com/orgs/nodejs/discussions/52547)
We have a build infrastructure where we install Node.js and pnpm (via corepack) into a build folder which is then subsequently used to run install commands etc. COREPACK_HOME is also placed there (inside the Node.js installation folder) and It's never expected to be mutated after the initial installation thus the entire folder is marked read-only. This also makes it more likely to have reproducible builds. The issue we are facing now is that running
corepack pnpm
(orpnpm
directly) with COREPACK_HOME set to the previously mentioned read-only folder results in an error along the lines of:Any ideas why this is the case? Why should
corepack
need write-access tolastKnownGood.json
even though I have set COREPACK_DEFAULT_TO_LATEST to 0 and don't even allow network access? Is there a way to prevent that from happening without bypassing corepack entirely?How to reproduce it
We can easily reproduce the issue by creating a docker environment (I've used the latest ubuntu image here):
then installing Node.js and pnpm in the docker environment, creating a guest user and switching to the guest user account
Now we can try to run pnpm after setting
COREPACK_HOME
etc. againwhich will spit out one of the above error.