Navigation Menu

Skip to content
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 · 14 comments
Closed

go: writing stat cache:, permission denied #26814

zongUMR opened this issue Aug 5, 2018 · 14 comments

Comments

@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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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 as completed Aug 5, 2018
@zsy619
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

@Emixam23
Copy link

Emixam23 commented Sep 9, 2019

Still doesn't work for me :( OSX user

@ianlancetaylor
Copy link
Contributor

@Emixam23 This issue was closed months ago. I recommend that you ask on a forum, providing details as to what happened; see https://golang.org/wiki/Questions. If you are sure you have encountered a bug, please feel free to file a new issue.

@DeaglePC
Copy link

chmod +wr -R /User/zongmeng/go/src/mod/cache/download/github.com/manucorporat

@wwwvmware
Copy link

your GOPATH is /Users/zongmeng/go why he open /User/zongmeng/go?

@herohenu
Copy link

do u use Ubuntu 18.04 on windows 10 ?
do u use Mcafee Endpoint Security ?
if so just search and find ubuntu1804.exe in your system
then right click ubuntu1804.exe-> properties -> compatibility(second tab) -> Setting(select run as administration ) ,then click Application (A) , all is ok ;

if it still build fail ,please click security tab , and click Advaced(V)
make sure your account access has Complete control ,default all allow is TrustedInstaller user ,this will prevented by Mcafee ;

wish it helped all who met this err ,I had troubled by it for months ;

@13015517713
Copy link

chmod +wr -R /User/zongmeng/go/src/mod/cache/download/github.com/manucorporat

chmod +wr -R /User/zongmeng/go/src/mod/cache/download/github.com/manucorporat

It's just a solution for manucorporat.Many files have the same problem.

@Vi1234sh12
Copy link

Anyone can you help me with this permission denied challenge

Screenshot (580)

@Davo36
Copy link

Davo36 commented Aug 19, 2021

I just solved this problem on my Windows machine. At first I had thought it was a file permissions problem. But it was a GOPATH environment variable problem.

I had it set to 2 values: C:\Program Files\Go (which is where I installed Go) and C:.... which was where I wanted all my Go projects to go.

So I removed the first entry. Just leaving GOPATH to point to the place on my hard drive where I wanted all my projects, and hey presto, problems gone, all tools installed correctly.

This may have been due to a previous version of Go not being entirely removed.

@Galileo72
Copy link

I just solved this problem on my Windows machine. At first I had thought it was a file permissions problem. But it was a GOPATH environment variable problem.

I had it set to 2 values: C:\Program Files\Go (which is where I installed Go) and C:.... which was where I wanted all my Go projects to go.

So I removed the first entry. Just leaving GOPATH to point to the place on my hard drive where I wanted all my projects, and hey presto, problems gone, all tools installed correctly.

This may have been due to a previous version of Go not being entirely removed.

Thank you so much ! .
Your comment solved my issue.

Regards.-

L.C

@manuelpcl
Copy link

I just solved this problem on my Windows machine. At first I had thought it was a file permissions problem. But it was a GOPATH environment variable problem.

I had it set to 2 values: C:\Program Files\Go (which is where I installed Go) and C:.... which was where I wanted all my Go projects to go.

So I removed the first entry. Just leaving GOPATH to point to the place on my hard drive where I wanted all my projects, and hey presto, problems gone, all tools installed correctly.

This may have been due to a previous version of Go not being entirely removed.

Thanks this worked for me, just setting the GOPATH to the folder were y had all my projects

@golang golang locked as resolved and limited conversation to collaborators Jan 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests