Search code examples
xcodegovisual-studio-codedelve

M1 Mac: Debugging Fails for golang via vscode


When launching the debugger from VSCode for golang (a launch.json that once worked).

I get the following error message in VSCode via a popup.

Failed to launch: could not launch process: fork/exec /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver: no such file or directory

Trying to launch the debugserver directly I get the following:

$ /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver -D -F -R 127.0.0.1:30000 /path/to/go/file.go
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1500.0.404.7
 for arm64.
error: failed to launch process /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver: Permission denied
Exiting

The google queries I ran all were for x86 installs of these tools, which isn't my issue.


Solution

  • For me, the following was the issue:

    launch.json

    {
          "name": "CLI: Useful name",
          "type": "go",
          "request": "launch",
          "mode": "auto",
          "program": "cmd/gofile.go",
          "cwd": "/Users/username/github/path/does/not/exist",
          "buildFlags": "-tags=dev",
          "console": "integratedTerminal",
          "args": [
            "my:args"
          ]
        }
    

    The path under cwd didn't exist, make sure you cwd points to a dir that exists.