16

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
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
user14892075
  • 171
  • 1
  • 1
  • 3

8 Answers8

45

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

enter image description here

Mr. Crowley
  • 3,225
  • 4
  • 25
  • 28
9

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

  1. Install golang for arm64. The easiest way is brew install golang if you have the arm64 version of brew, which is working very well now. This will get you golang v1.16-beta1 at this time.
  2. Install the Apple Silicon version of Goland
  3. Check out delve. The PR has already been merged, git clone https://github.com/go-delve/delve, then build it with cd delve && make install, which will put delve in ~/go/bin/dlv
  4. 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).
  5. Restart Goland
rfay
  • 9,963
  • 1
  • 47
  • 89
2

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:

  1. https://youtrack.jetbrains.com/issue/GO-10235
  2. https://github.com/go-delve/delve/issues/2246

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.

Jens
  • 20,533
  • 11
  • 60
  • 86
1

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:

  1. Go:Choose go Environment
  2. Choose or Get go1.17.3/ upper version
  3. Press F5 - It will warn you delve not install or directly install >Go: Install/Update Tools - then select delve.
1

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!

lupguo
  • 1,525
  • 13
  • 13
0

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.

user14892075
  • 171
  • 1
  • 1
  • 3
0

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.

setup arch

Anh Nhat Tran
  • 561
  • 1
  • 6
  • 18
0

this worked for goenv

arch -arch x86_64 goenv install

and asdf

ASDF_GOLANG_OVERWRITE_ARCH=amd64 asdf install
tuwilof
  • 351
  • 3
  • 6