New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: writing stat cache:, permission denied #26814

Closed
zongUMR opened this Issue Aug 5, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@zongUMR
Copy link

zongUMR commented Aug 5, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.11beta2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zongmeng/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/zongmeng/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/66/h198vsq94gjbzhkj2vbg1rqr0000gn/T/go-build558650207=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

I have a simple project that uses go mod. when I open the project in VSCode, it show the follow error for me:

go: finding github.com/gin-gonic/gin v1.1.4
go: finding github.com/golang/protobuf v1.1.0
go: finding github.com/mattn/go-isatty v0.0.3
go: finding github.com/fatih/structs v1.0.0
go: finding github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739
go: writing stat cache: open /User/zongmeng/go/src/mod/cache/download/github.com/manucorporat/sse/@v/v0.0.0-20160126180136-ee05b128a739.info.tmp-461144603: permission denied
go: writing stat cache: open /User/zongmeng/go/src/mod/cache/download/github.com/gin-gonic/gin/@v/v1.1.4.info.tmp-063973566: permission denied
go: writing stat cache: open /User/zongmeng/go/src/mod/cache/download/github.com/golang/protobuf/@v/v1.1.0.info.tmp-237748485: permission denied
go: writing stat cache: open /User/zongmeng/go/src/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.3.info.tmp-024245408: permission denied
go: writing stat cache: open /User/zongmeng/go/src/mod/cache/download/github.com/fatih/structs/@v/v1.0.0.info.tmp-128475519: permission denied
go: writing go.mod cache: open /User/zongmeng/go/src/mod/cache/download/github.com/gin-gonic/gin/@v/v1.1.4.mod.tmp-010532562: permission denied
go: writing go.mod cache: open /User/zongmeng/go/src/mod/cache/download/github.com/manucorporat/sse/@v/v0.0.0-20160126180136-ee05b128a739.mod.tmp-504665609: permission denied
go: writing go.mod cache: open /User/zongmeng/go/src/mod/cache/download/github.com/golang/protobuf/@v/v1.1.0.mod.tmp-027138004: permission denied
go: writing go.mod cache: open /User/zongmeng/go/src/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.3.mod.tmp-102994211: permission denied
go: writing go.mod cache: open /User/zongmeng/go/src/mod/cache/download/github.com/fatih/structs/@v/v1.0.0.mod.tmp-207383078: permission denied
go: finding gopkg.in/yaml.v2 v2.2.1
go: writing stat cache: open /User/zongmeng/go/src/mod/cache/download/gopkg.in/yaml.v2/@v/v2.2.1.info.tmp-428832589: permission denied
go: writing go.mod cache: open /User/zongmeng/go/src/mod/cache/download/gopkg.in/yaml.v2/@v/v2.2.1.mod.tmp-323851336: permission denied
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: finding gopkg.in/go-playground/validator.v8 v8.18.2
go: writing stat cache: open /User/zongmeng/go/src/mod/cache/download/gopkg.in/check.v1/@v/v0.0.0-20161208181325-20d25e280405.info.tmp-817140487: permission denied
go: writing stat cache: open /User/zongmeng/go/src/mod/cache/download/gopkg.in/go-playground/validator.v8/@v/v8.18.2.info.tmp-273428666: permission denied
go: writing go.mod cache: open /User/zongmeng/go/src/mod/cache/download/gopkg.in/check.v1/@v/v0.0.0-20161208181325-20d25e280405.mod.tmp-604255953: permission denied
go: writing go.mod cache: open /User/zongmeng/go/src/mod/cache/download/gopkg.in/go-playground/validator.v8/@v/v8.18.2.mod.tmp-086728188: permission denied
go: golang.org/x/net@v0.0.0-20180801234040-f4c29de78a2a: unrecognized import path "golang.org/x/net" (https fetch: Get https://golang.org/x/net?go-get=1: dial tcp 172.217.194.141:443: i/o timeout)
go: error loading module requirements

I got into this first wrong dictionary/User/zongmeng/go/src/mod/cache/download/github.com/manucorporat/sse/@v and check its permission:
ls -l, it shows:
screen shot 2018-08-05 at 4 41 55 pm
)

Other problem is same

What did you expect to see?

What did you see instead?

As the image shows, the two files don't have enough permission. They were created by go mod automatucally. I am not sure that is normal or not

@agnivade

This comment has been minimized.

Copy link
Member

agnivade commented Aug 5, 2018

You have somehow executed the go command as root. And probably running VSCode as normal user.

This does not seem to be a Go issue.

Either run everything as root, or run everything as normal user.

@zongUMR

This comment has been minimized.

Copy link

zongUMR commented Aug 5, 2018

@agnivade Thanks for your help. When I run VSCode as a root, it does not show the errors, but it notify me that don't run it as a root. I am weird about how I can resolve the problem directly

@agnivade

This comment has been minimized.

Copy link
Member

agnivade commented Aug 5, 2018

This is a system issue. You can chown -R the /User/zongmeng/go/src directory so that everything can run as normal user. But if you run go as root again, this will re-appear.

I will close this as this is not a Go issue. Please direct further questions to forums in Questions wiki page; folks will be happy to help you out.

@agnivade agnivade closed this Aug 5, 2018

@zsy619

This comment has been minimized.

Copy link

zsy619 commented Dec 9, 2018

sudo chown -R $(whoami):admin /Users/zhushuyan/go/pkg && sudo chmod -R g+rwx /Users/zhushuyan/go/pkg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment