Incremental build with gatsby gives error

Hi,

I am trying out this new feature, however, I get this error from the picture attached:

Plugin “netlify-plugin-gatsby-cache” internal error
Error: Cannot cache /opt/build/repo because it is the current directory (/opt/build/repo) or a parent directory

I followed the instructions here https://www.netlify.com/blog/2020/04/23/enable-gatsby-incremental-builds-on-netlify/, except my gatsby already upgraded to 2.21.24.

Any ideas why is this happening and how to solve this? Thanks!

Actually I finally got it working by adding these to netlify.toml
[build.environment]
YARN_VERSION = “1.22.4”
NODE_VERSION = “12.16.3”

Perfect; thanks for feeding back!

Hi,
I was not getting this error in previous builds, but now I don’t know why this error is showing up, I also tried the below modification to netlify.toml

my current netlify.toml file configurations are:


[build.environment]
  YARN_VERSION = "1.22.4"
  NODE_VERSION = "12.16.3"

  
[[plugins]]
  package = "netlify-plugin-gatsby-cache"

And the error shows up as

Plugin “netlify-plugin-gatsby-cache” internal error

Error: Cannot cache /opt/build/repo because it is the current directory (/opt/build/repo) or a parent directory

In “onPreBuild” event in “netlify-plugin-gatsby-cache” from netlify.toml at checkSrcPath (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/cache-utils/src/path.js:44:11) at getSrcPath (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/cache-utils/src/path.js:18:3) at async parsePath (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/cache-utils/src/path.js:9:19) at async restoreOne (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/cache-utils/src/main.js:37:34) at async Promise.all (index 0) at async allowMany (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/cache-utils/src/main.js:84:19) at async onPreBuild (/opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-gatsby-cache/index.js:12:9) at async Object.run (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/run.js:13:3) at async handleEvent (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/main.js:34:38) at async process. (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/ipc.js:102:9)


I have tried to redeploy a couple of times also still facing the same error Any idea of how to solve this and what's causing this error? Thanks!

hi there, sorry to be slow to get back to you! any changes to this - were you able to figure it out? if not, i will go ask and see if we can get you some more help.

Hey, Sorry to get back so late, I tried 10’s of builds reinstalling plugin, deleted the site and redeployed many times…But it doesn’t seem to work so I rather removed the incremental build feature than wasting my builds. Since I have not yet made my site public it didn’t cause much of a harm.

So, it would be really great if you’ll could help me with that.

Hi @jaymgurav,

This error should indicate that the publish directory is misconfigured for a Gatsby setup.
Could you please print the full build logs showing the error? Thanks!
Note: the Gatsby cache plugin version should be the latest, i.e. 0.3.2.