build: Error `ENOENT: no such file or directory, open '/opt/build/cache/cwd/.cache.netlify.cache.json'`

The following error (or a variant) is thrown in some build logs:

Error: ENOENT: no such file or directory, open '/opt/build/cache/cwd/.cache.netlify.cache.json' 

This was also reported in https://github.com/jlengstorf/netlify-plugin-gatsby-cache/issues/24.

Bugsnag error

Other Bugsnag error

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

This is fixed by #1710. I will update this issue once the fix is in production.

Yes, also confirmed! Good work!

I can confirm this bug is now fixed in production.

Awesome, thanks a lot @ehmicky ! OK, will remove the workaround once it’s merged.

Hi @tilsammans and @cdeleeuwe,

The fix mentioned above was deployed to production and solved some of the *.netlify.cache.json errors. However, the bug was still happening when trying to cache empty nested directories (e.g. /resources/assets/ in the Hugo cache plugin case). I created a PR at #1772 that fixes this problem. I managed to reproduce the bug, so this PR should do the job.

Once deployed to production, I will update this PR. In the meantime, the workaround mentioned by @cdeleeuwe also works (note: that workaround can be removed if you want once the PR above is in production).