build-image
build-image copied to clipboard
go cache handling seems perhaps wrong?
I don't know if very many people use the Go cache, but this customer (who does use go during build) sees build errors like these when trying to restore his cache:
6:52:22 PM: mv: cannot remove '/opt/build/cache/.gimme_cache/.gimme_cache/gopath/pkg/mod/github.com/aws/[email protected]/LICENSE-LAMBDACODE': Permission denied (note the double .gimme_cache/.gimme_cache)
and
6:52:22 PM: mv: cannot remove '/opt/build/cache/.gimme_cache/gopath/pkg/mod/github.com/aws/[email protected]/events/kinesis_test.go': Permission denied (no double path but still errors)
You can find a link to the deploy in question here: https://netlify.slack.com/archives/C179K6Y0K/p1552946023889400
Yeah, I looked into this yesterday. For some reason we can't read/write to the cache folder in the docker image.
I think we ran into the same problem a few months ago. It came with the newer go versions (we use 1.11.5 with go.mod).
go get (build) saves the third party dependencies files with readonly permission (-r--r--r-- or 444).
Netlify build-image cache logic tries to move this readonly files from the GOPATH/pkg/mod directory to the cache directory (/opt/build/cache/.gimme_cache/....) in the after_build_steps phase (at the end of the netlify build). It also tries to move this readonly files from the cache directory to the GOAPTH/pkg/mod directory in the install_dependencies phase (at the beginning of the netlify build).
We use a (not too elegant) fix/hack at the end of our build script, we give write permission to these files with this command: chmod +w "$GOPATH/pkg/mod"
Theoretically it should be enough, but sometimes we got these error messages again, so we ended up to changing these directories (if those exist):
- $GOPATH/pkg/mod
- /opt/buildhome/.gimme_cache/gopath/pkg/mod
- /opt/buildhome/.gimme_cache/.gimme_cache/gopath/pkg/mod
- /opt/build/cache/.gimme_cache/.gimme_cache/gopath/pkg/mod
- /opt/build/cache/.gimme_cache/gopath/pkg/mod
I only see this repo, so I don't know how netlify caching mechanism works, but the '/opt/build/cache/.gimme_cache/.gimme_cache/gopath/pkg/mod/.....' path is also very weird.
Thank you for the extra pointers @ImreZol. We should address this issue asap.
I also have this issue with my Gatsby project:
11:12:15 PM: chmod: cannot access '/opt/buildhome/.gimme_cache'
Any progression in this case? I cannot deploy my production website currently.