-
Bug
-
Resolution: Unresolved
-
Minor
-
linux
No error for directly running docker command:
docker run --rm \ -w /go/src/$BASEDIR/$PROJECT \ -v $(pwd):/go/src/$BASEDIR/$PROJECT \ -it golang:1.10 \ make build
error occurs when running in jenkins:
docker.image('golang:1.10').inside { sh 'go version' sh 'pwd' sh 'env' sh 'mkdir -p $GOPATH/src/$BASEDIR; ln -sf `pwd` $GOPATH/src/$BASEDIR/$PROJECT' sh 'cd $GOPATH/src/$BASEDIR/* && make build' }
error message:
GOOS=linux go build -tags prod -ldflags='-w -s ' -o main
go: disabling cache (/.cache/go-build) due to initialization failure: mkdir /.cache/go-build/00: permission denied
see
1. test project
2. github issue
The problem is that go assumes (not unreasonably) that you will have write access to $XDG_CACHE_HOME if it exists and $HOME/.cache if it does not
https://golang.org/src/cmd/go/internal/cache/default.go?s=2439:2657
The fix is to set XDG_CACHE_HOME to something that is universally writable like /tmp/.cache or something like that.
SEE: https://github.com/docker-library/golang/issues/225