jlengstorf / netlify-plugin-gatsby-cache

185 stars 21 forks source link

Wrong `PUBLISH_DIR` #23

Closed ehmicky closed 4 years ago

ehmicky commented 4 years ago

Many production builds are reporting the following error:

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

This comes from this line of code in utils.cache.restore().

This is turn indicates that either PUBLISH_DIR or PUBLISH_DIR/../.cache is the build/base directory. This seems to be due to a user misconfiguration, but considering the error happened frequently, I will investigate more.

If any users having this issue is reading this, feel free to chime in.

jlengstorf commented 4 years ago

@ehmicky is there a variable for the base dir? we could do something like

if (PUBLISH_DIR === BASE_DIR) {
  failPlugin('your publish directory appears to be misconfigured')
}
ehmicky commented 4 years ago

The build directory is process.cwd() inside Build plugins.

The error message above is actually doing something similar but inside the utils.cache directly.

jlengstorf commented 4 years ago

this was fixed a while back and I forgot to close this

ehmicky commented 4 years ago

Thanks for updating @jlengstorf. The error has not been triggered in one month indeed :+1: