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

cmd/go: go build fails with permission error inside a temporary directory on Windows #42224

Open
zhaoyunxing92 opened this issue Oct 27, 2020 · 7 comments

Comments

@zhaoyunxing92
Copy link

@zhaoyunxing92 zhaoyunxing92 commented Oct 27, 2020

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

$ go version
go version go1.15.3 windows/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\zyx\AppData\Local\go-build
set GOENV=C:\Users\zyx\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\gopath
set GOPRIVATE=
set GOPROXY=https://goproxy.io,direct
set GOROOT=D:\software\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\software\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\code\github\go\go-mongo\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\zyx~1\AppData\Local\Temp\go-build500345966=/tmp/go-build -gno-record-gcc-switches

What did you do?

go run main.go

What did you expect to see?

What did you see instead?

open C:\Users\zyx~1\AppData\Local\Temp\go-build933307734\b001\exe\a.out.exe: The process cannot access the file because it is being used by another process.

@davecheney
Copy link
Contributor

@davecheney davecheney commented Oct 27, 2020

Thank you for raising this issue. Anti virus software often causes problems on windows systems. Would you be able to temporarily disable your AV software and see if that makes a difference?

@zhaoyunxing92
Copy link
Author

@zhaoyunxing92 zhaoyunxing92 commented Oct 27, 2020

Thank you for raising this issue. Anti virus software often causes problems on windows systems. Would you be able to temporarily disable your AV software and see if that makes a difference?

thank you for your reply,I can't close it,I wonder if modifying his build directory can be solved

@davecheney
Copy link
Contributor

@davecheney davecheney commented Oct 27, 2020

As a workaround can you try using go build to build the binary, then run the resulting .exe and see if that helps?

@zhaoyunxing92
Copy link
Author

@zhaoyunxing92 zhaoyunxing92 commented Oct 27, 2020

As a workaround can you try using go build to build the binary, then run the resulting .exe and see if that helps?

the same mistake,whether to change the directory of GOGCCFLAGS can be resolved,but it doesn't seem like it can be changed

@davecheney
Copy link
Contributor

@davecheney davecheney commented Oct 27, 2020

the same mistake,

Can you please post the entire output you see. Do not use a screenshot.

whether to change the directory of GOGCCFLAGS can be resolved,but it doesn't seem like it can be changed

This seems unrelated. Please open a new issue so it can be addressed independently. Thank you

@zhaoyunxing92
Copy link
Author

@zhaoyunxing92 zhaoyunxing92 commented Oct 27, 2020

the same mistake,

Can you please post the entire output you see. Do not use a screenshot.

whether to change the directory of GOGCCFLAGS can be resolved,but it doesn't seem like it can be changed

This seems unrelated. Please open a new issue so it can be addressed independently. Thank you

12:55 [xyz@docker go-mongo ] (develop) go build main.go
open C:\Users\zyx~1\AppData\Local\Temp\go-build060591562\b001\exe\a.out.exe: The process cannot access the file because it is being used by another process.
@dmitshur dmitshur added this to the Backlog milestone Oct 30, 2020
@dmitshur dmitshur added the OS-Windows label Oct 30, 2020
@dmitshur dmitshur changed the title The process cannot access the file because it is being used by another process. cmd/go: go build fails with permission error inside a temporary directory on Windows Oct 30, 2020
@dmitshur
Copy link
Member

@dmitshur dmitshur commented Oct 30, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.