Access denied when launching VScode Go code both running without debugging and with debugging

4.1k views Asked by At

I'm trying to setup a new Windows dev machine for Go and what is usually a pretty simple process has been met with a lot of headaches. When I try to run without debugging I get the following error:

fork/exec C:\Users\CAMIWIL\AppData\Local\Temp\go-build588834862\b001\exe\hello.exe: Access is denied. Process exiting with code: 1 signal: false

Likewise when I try to run with debugging I get:

could not launch process: fork/exec c:\dev\hello__debug_bin: Access is denied. Process exiting with code: 1

What's interesting is in the second case, if I run dlv manually on my code using a git bash it has no issues creating the __debug_bin file and I can debug to my hearts content. Likewise I can also build the code using command line as well. I also tried installing goland just to see if it had any issues, and that also seems to be working fine. I'm basically using VScode as is, I've only installed it along with the go extension at this point.

Anyone have any clue one what might be the cause of this? And what the resolution may be?

3

There are 3 answers

0
samatthias On

In my case I had to add an exclusion to my antivirus software to C:\Users\CAMIWIL\AppData\Local\Temp. After this step, I was able to run the go program without problems.

0
nqramjets On

I know this is an old question but I came across this today and finally got it sorted out.

This was answered tangentially on SO here.

Short version is that you need to have your main.go file in focus when you hit F5 or Ctrl+F5 in order for VSCode the refer the correct file to be run/the debugger. A second answer on that post indicates that you cansetup your launch.json to explicitly launch main.go always, eliminating this super annoying quirk.

0
Dagm Fekadu On

Sometime docker doesn't allow you to access files in the remote container. Use this docker option to run your container --security-opt=seccomp:unconfined