pnpm: ENOENT: no such file or directory, copyfile

Also having this issue after upgrading to v7. I have no idea how to reproduce it though… it works again by nuking the whole store and re-downloading everything.

 ENOENT  ENOENT: no such file or directory, copyfile '/Users/work/.pnpm-store/v3/files/68/fd2865a3cee2a68927ffed7c54667b1b3b03710b6a174ad45caa8e05f2e033b51e6d6f55ab22d8207f2fdb286c9dd057cb43171aa793ce9f180da8d7653e6e' -> '/Users/work/redacted/redacted/node_modules/.pnpm/fsevents@1.2.13/node_modules/_tmp_10595_695eb2b63757fc332de5b4c217d64f1d/build/.target.mk'

This is in MacOS by the way.

_Originally posted by @rdsedmundo in https://github.com/pnpm/pnpm/issues/3229#issuecomment-1149057063_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 23
  • Comments: 33 (8 by maintainers)

Commits related to this issue

Most upvoted comments

ran into this on Mac Silicon after pnpm store prune

fixed by removing the store folder with rm -rf ~/Library/pnpm/store/v3/files/

I ran into this issue. My solution:

  • rm pnpm-lock.yaml
  • rm -rf node_modules
  • rm -rf ~/Library/pnpm
  • pnpm install

Then it works.

I think I understand how the store can become corrupted by pnpm store prune. When we clear the store, we check the link attribute of the files. If nlink is 1, we assume that is not used anywhere, because no hard links are pointing to it. However, sometimes pnpm fails to create a hard link to the file in the store and it falls back to making a copy.

~I still don’t understand though how could it fail without verify-store-integrity=false. As far as I understand, not everyone with the issue have disabled store integrity verification.~

OK, I understand why it happens! It happens with packages that have side-effects cache. We don’t verify the integrity of the files from the side-effects cache.

I ran into this issue after pnpm prune and pnpm store prune

pnpm: ENOENT: no such file or directory, copyfile ‘~/Library/pnpm/store/v3/files/3e/bb8d0e7c4cabc1e6cc88debae8e0b66114e9d3a7fd019b1ed6a9f391fa8dc9b15106b53d8620a3578354cc55adac18ac148c3f6c333b520151df2a733c1659-exec’ -> ‘…/v5/node_modules/.pnpm/nodemon@2.0.19/node_modules/_tmp_70154_6224b9e6c68d68771e5687ef6d93f3e8/node_modules/.bin/nodemon’

not sure if this is related to nodemon postinstall scripe, but pnpm i --ignore-scripts solves my issue

OK, that is good. Then probably someone with a mac can investigate this.

Yep, i ran pnpm store prune too and then i have this problem fixed by removing the store

I can reproduce this error if I set verify-store-integrity to false and I remove a file from the store.

As a temporary workaround, adding hints to the error message sounds good.

Hey @zkochan , what’s happening in my situation might help you to debug further, here it goes:

  1. Everything was working fine on pnpm v6
  2. Upgraded to pnpm v7 and started having this issue’s error on a container (CI)

CI STAGES

  1. [UPDATE_CACHE] I’m caching pnpm store to use in later stages, and when doing so, I’m running the following commands:
    • pnpm config set store-dir ${CI_PROJECT_DIR}/.pnpm-store (setting the store path)
    • pnpm install --frozen-lockfile -r (installing deps)
    • pnpm store prune (removing unused deps)
  2. [PROJECT_BUILD] After updating the cache, I’m actually building the project and before doing that, I’m running:
    • pnpm install --frozen-lockfile --no-verify-store-integrity -r (which should take advantage of the previous cache) => 🔴 it is while installing the deps that I get the “ENOENT  ENOENT: no such file or directory, copyfile …” error

WORKAROUNDS

So far, I was able to work around this with 2 different “solutions”:

  1. Not pruning the store on the “update-cache” stage
  2. Removing the --no-verify-store-integrity from the install stage

Does anything else comes to mind, or do you see any type of “conflicts” with the current setup?

I ran into this by(in a pnpm monorepo):

rm -rf node_modules
pnpm store prune
pnpm i

env: apple m2, macOS 13.0