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

Created on 2 Jun 2020  ·  18Comments  ·  Source: netlify/build

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

bug

Most helpful comment

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

All 18 comments

This issue has been linked to an error in Bugsnag
pluginInternal in Plugin "netlify-plugin-hugo-cache-resources" internal error

Core bug

Comment added in Bugsnag by Mickael Hebert
pluginInternal in Plugin "netlify-plugin-hugo-cache-resources" internal error

@ehmicky Is there any workaround I could implement to fix this issue in the netlify-plugin-hugo-cache-resources plugin?

Hi @cdeleeuwe,

I am witnessing this bug in production, but am having trouble reproducing it. Did you manage to reproduce it?

I opened an issue on @cdeleeuwe's github. This seems to be happening on my website, https://github.com/sathyabhat/sathyasays.com

I removed the plugin and installed again but without success.

@SathyaBhat, is this happening consistently?
If so, would it be possible for you to share a link to your deploy logs? Thanks!
Edit: I found your deploy logs. It does seem to appear consistently in your case.

I managed to reproduce this problem in a fork: deploy logs, PR

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

An error linked to this issue has been marked as fixed in Bugsnag
pluginInternal in Plugin "netlify-plugin-hugo-cache-resources" internal error

An error linked to this issue has been reopened in Bugsnag
pluginInternal in Plugin "netlify-plugin-hugo-cache-resources" internal error

Hi @ehmicky did you manage to deploy the fix?

Today it's still a bug for me with the Hugo Cache Resources plugin. Anything to do for the plugin authors?

@tilsammans For now I have pushed a workaround fix. Hopefully this fixes the problem for you.

Hey @cdeleeuwe thanks for looking into it! Unfortunately, Hugo Cache Resources is still broken.

2:54:33 PM:   Error: ENOENT: no such file or directory, open '/opt/build/cache/cwd/resources.netlify.cache.json'
2:54:33 PM: ​
2:54:33 PM:   Plugin details
2:54:33 PM:   Package:        netlify-plugin-hugo-cache-resources
2:54:33 PM:   Version:        0.1.4
2:54:33 PM:   Repository:     git+https://github.com/cdeleeuwe/netlify-plugin-hugo-cache-resources.git
2:54:33 PM:   npm link:       https://www.npmjs.com/package/netlify-plugin-hugo-cache-resources
2:54:33 PM:   Report issues:  https://github.com/cdeleeuwe/netlify-plugin-hugo-cache-resources/issues
2:54:33 PM: ​
2:54:33 PM:   Error location
2:54:33 PM:   In "onPostBuild" event in "netlify-plugin-hugo-cache-resources" from Netlify app
2:54:33 PM: ​
2:54:33 PM:   Error properties
2:54:33 PM:   {
2:54:33 PM:     errno: -2,
2:54:33 PM:     code: 'ENOENT',
2:54:33 PM:     syscall: 'open',
2:54:33 PM:     path: '/opt/build/cache/cwd/resources.netlify.cache.json'
2:54:33 PM:   }

@tilsammans sure no problem. Actually, I pushed the fix in version 0.1.5 and master, but it hasn't been updated in Netlify yet (PR is still open https://github.com/netlify/plugins/pull/131).

Not sure if you have enabled the plugin through the Netlify UI or netlify.toml file, but if you want to use it now, you can use the latest version through the netlify.toml file.

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).

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

I can confirm this bug is now fixed in production.

Yes, also confirmed! Good work!

Was this page helpful?
0 / 5 - 0 ratings