'GoLand on Apple Silicon can not debug golang project
Edit 2021-01-28: This whole question is now obsolete because GoLand 2020.3.2 was released today, and it includes a working delve. Don't forget to remove alterations you might have made, as the release notes point out.
I am trying to debug golang project with GoLand on Apple Silicon, but it does not work; error following:
API server listening at: [::]:62619
debugserver-@(#)PROGRAM:LLDB PROJECT:lldb-1200.0.44 for x86_64.
error: failed to launch process /Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/debugserver: (os/kern) invalid argument
Exiting.
could not launch process: stub exited while waiting for connection: exit status 0
Solution 1:[1]
I have golang 1.16.6 and still facing the same issue with this error message:
Use go sdk for darwin/arm64
my solution was to add the following ENVs
GOOS=darwin, GOARCH=arm64
Solution 2:[2]
Edit 2021-01-28: This whole question (and this answer) are now obsolete because GoLand 2020.3.2 was released today, and it includes a working delve. Don't forget to remove alterations you might have made, as the release notes point out.
Spurred on by user14892075's answer and mostly by https://www.reddit.com/r/golang/comments/kqgxel/debugging_wcli_and_goland_works_on_apple_m1/ here's the technique until there's an official release of Goland and also of dlv
- Install golang for arm64. The easiest way is
brew install golangif you have the arm64 version of brew, which is working very well now. This will get you golang v1.16-beta1 at this time. - Install the Apple Silicon version of Goland
- Check out delve. The PR has already been merged,
git clone https://github.com/go-delve/delve, then build it withcd delve && make install, which will put delve in ~/go/bin/dlv - Open Goland and go to Help->Edit Custom VM Options. Add a line there with
-Ddlv.path=/Users/rfay/go/bin/dlv(change the username from rfay to yours, or edit the path to be the full path to the dlv you built). - Restart Goland
Solution 3:[3]
GoLand uses Delve as debugger. Delve does not support Apple Silicon yet.
There are bug tickets at Jetbrains and Delve to track this. I suggest you watch those tickets for updates:
But don't expect something "stable" and official until Go version 1.16, which has official Apple Silicon support. At the moment, release is scheduled for February.
Go supporting Apple Silicon is probably the prerequisite for Delve working on Apple Silicon, since debugging through Rosetta does not seem feasible. So Delve needs to be compiled with Go 1.16 to work natively on Apple Silicon.
Therefore, official Apple Silicon support for Delve probably will not happen before February 2021.
Solution 4:[4]
I already had have installed version of go(darwin) which is 1.16 and delve before. I tried set environment like ( "env": {"GOOS":"darwin", "GOARCH":"arm64"}) and update packages and these are didn't work.
I solved the problem in VSCode with these steps:
- Go:Choose go Environment
- Choose or Get go1.17.3/ upper version
- Press F5 - It will warn you delve not install or directly install >Go: Install/Update Tools - then select delve.
Solution 5:[5]
It works now.See :https://github.com/oxisto/delve/tree/darwin-arm64-lldb it hasn't merge to master branch;'go build' it and replace Goland dlv plugin, then Degbugger works.
Solution 6:[6]
I faced the same issue today with Goland 2022.3. You need to use the correct go version for mac M1. Then updating GOARCH can help.
I fixed this error by going to Preferences -> Go -> Build Tags & Vendoring, then on Arch, update the value to arm64.
Solution 7:[7]
I have the same problem on my Apple M1 Pro, i have installed Apple Silicon Goland(2021.3.4 apple silicon version) And Golang(1.18 drawin/arm64).
Because i migrate from an old machine(2019 Mac Pro) to a new one(2021 Mac M1). My /Applications/Xcode.app/Contents/Developer is old leader this problem.
Try:
// remove CommandLineTools
$ sudo rm -rf /Library/Developer/CommandLineTools
// reinstall, about 20min
$ xcode-select --install
Then everything is OK!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mr. Crowley |
| Solution 2 | |
| Solution 3 | Jens |
| Solution 4 | Necdet Yi?it ERO?LU |
| Solution 5 | user14892075 |
| Solution 6 | Anh Nhat Tran |
| Solution 7 | lupguo |


