user14892075
user14892075

Reputation: 171

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

Upvotes: 16

Views: 21944

Answers (9)

jnipher z
jnipher z

Reputation: 1

It was able to resolve it via removal and installation of xcode command line tools:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

It work fine for me

Upvotes: 0

tuwilof
tuwilof

Reputation: 587

this worked for goenv

arch -arch x86_64 goenv install

and asdf

ASDF_GOLANG_OVERWRITE_ARCH=amd64 asdf install

Upvotes: 0

lupguo
lupguo

Reputation: 1651

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!

Upvotes: 1

Anh Nhat Tran
Anh Nhat Tran

Reputation: 562

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

Upvotes: 0

Necdet Yiğit EROĞLU
Necdet Yiğit EROĞLU

Reputation: 19

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.

Upvotes: 1

Mr. Crowley
Mr. Crowley

Reputation: 3403

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

Upvotes: 46

rfay
rfay

Reputation: 13045

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

Upvotes: 9

user14892075
user14892075

Reputation: 171

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.

Upvotes: 0

Jens
Jens

Reputation: 21540

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.

Upvotes: 2

Related Questions