5

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?

luepin
  • 51
  • 1
  • 3
  • Check your launch.json file and see if it is running right command – Shubham Srivastava Oct 16 '20 at 04:06
  • It might be the VS Code is using directories (or parents thereof) that are not accessible by the user that is running the process. Have you tried restarting the IDE with administrator user privileges or changing where the exe is put? What are the go executable file attributes like? – Willeman Oct 16 '20 at 08:33
  • @luepin I think I have the same issue. I posted here but no luck so far unfortunately: https://superuser.com/questions/1585088/access-denied-removing-debug-bin-in-visual-studio-code – androidu Oct 27 '20 at 21:43

3 Answers3

2

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.

nqramjets
  • 76
  • 9
1

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.

samatthias
  • 63
  • 2
  • 7
0

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

Dagm Fekadu
  • 598
  • 1
  • 8
  • 22