Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51964

golang:1.10 mkdir /.cache/go-build/00: permission denied

      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

          [JENKINS-51964] golang:1.10 mkdir /.cache/go-build/00: permission denied

          wangoo yang added a comment -

          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

          wangoo yang added a comment - 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

            Unassigned Unassigned
            wangoo wangoo yang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: