Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dlv debug return error on mac m1 #2604

Closed
huguijian opened this issue Jul 19, 2021 · 29 comments
Closed

dlv debug return error on mac m1 #2604

huguijian opened this issue Jul 19, 2021 · 29 comments

Comments

@huguijian
Copy link

go version: go1.16.6 darwin/amd64
dlv version: 1.7.0

dlv debug
error:could not launch process: can not run under Rosetta, check that the installed build of Go is right for your CPU architecture

@aarzilli
Copy link
Member

Delve can not run under Rosetta, use go version to check that the installed build of Go is right for your CPU architecture.

@pratikjain227
Copy link

pratikjain227 commented Aug 20, 2021

I am using Apple M1 chip laptop
Facing the same error on Goland IDE Debugger, which is using delve behind the scenes

$ go version 
go version go1.16.6 darwin/arm64

It throws the same error when using go version go1.16.6 darwin/amd64

Not sure what else might be wrong, can you please guide @aarzilli

@givetimetolife
Copy link

I also encountered the same problem, I also used the m1 chip

@pratikjain227
Copy link

pratikjain227 commented Aug 26, 2021

I also encountered the same problem, I also used the m1 chip

This doc helped me resolve my issue -
https://blog.jetbrains.com/go/2021/01/28/goland-2020-3-2-is-out/

Edit: Not sure why are people disliking the comment, I have simply written what worked for me (doesn't necessarily mean that it will work for you)

@aravinthkumar
Copy link

aravinthkumar commented Jan 6, 2022

the issue still exist :(

@ndemeshchenko
Copy link

why is this issue closed? still doesn't work on m1

@aravinthkumar
Copy link

I was able to fix it myself, I had installed go darwin amd64 instead of darwin arm64
reinstalling fixed it

@vamseeakkiraju
Copy link

I tried installing arm64. Still issue persists.

@propainter
Copy link

@vamseeakkiraju after switching to arm -> install your go tools in VScode again. Then it will run fine

@gt-ow-1989
Copy link

why does this issue keep getting closed? It is not working on M1 even with all the above suggestions

@mhatch-nxcr
Copy link

@gt-ow-1989 - worked for me. i switched from amd64 to arm64. you can get it here (https://go.dev/dl/go1.17.8.darwin-arm64.pkg)

@jakpren
Copy link

jakpren commented Mar 16, 2022

Uninstall Golang(AMD-64 version).

  1. Install Golang(ARM-64). Confirm it with go env GOARCH
  2. Remove(tools that VS-Code uses) binaries from $GOPATH/bin (Important)
  3. Restart your VS-Code and install tools that VS-Code needed(if not installed vscode will complain and will ask you to install them)
    Root cause of the problem: I accidentally installed amd-64 version instead of arm-64 version in my Apple Mac M1.

@CamelCafeRider
Copy link

Only do this if you have installed not installed the "-arm64" version from go website.

Please delete the below listed directories.

Navigate to these directories in Finder App, on your Mac and delete.

/usr/{your_user_mac_user_name}/go (delete this directory)
/usr/your_user_mac_user_name/go (delete this directory)

For M1 Chip based, Macs we need to install the “go1.18.darwin-arm64.pkg” version.

Download and install from this link.

https://go.dev/dl/go1.18.darwin-arm64.pkg

If you use Visual Code:

Reinstall your Visual Code Extensions, and then, you should be able to debug, as I am able to.

Cheers

@carlca
Copy link

carlca commented Mar 16, 2022

I had same problem just now. I was able to solve it in 3 steps:

[1] Download and install the ARM64 installer package from https://golang.org - https://go.dev/dl/go1.18.darwin-arm64.pkg
[2] Run go install github.com/go-delve/delve/cmd/dlv@latest from the command-line.
[3] Run go install github.com/aarzilli/gdlv@latest from the command line.

Step 1 ensures that you have the M1 compatible version of Go.
Steps 2 and 3 ensure that the tools, Delve and GDlv, are built and installed using the M1 version of Go.

@gg-gg
Copy link

gg-gg commented Apr 2, 2022

If you use M1 chip and use goland IDE:

  1. check your go version, use arm64, not amd64
  2. check your goland version, download .dmg(apple slilicon), not .dmg(Intel), which this is default version. If you forget whick dmg you use, reinstall it with the apple dmg version.

@eryajf
Copy link

eryajf commented Apr 3, 2022

2. check your goland version, download .dmg(apple slilicon), not .dmg(Intel), which this is default version. If you forget whick dmg you use, reinstall it with the apple dmg version.

Thank you, I got inspiration from your answer. Indeed, my vscode is intel version. When I downloaded arm version vscode again, my debug was normal.

@ndombroski
Copy link

Also running on an M1 chip here. I believe my issue was not having the GOARCH environment variable set when I installed dlv. Despite that my installation of Go was correct, it would appear that without GOARCH being set, go install was defaulting to amd64 when installing the binary. Removing dlv from $GOBIN and reinstalling with the following command fixed this issue for me:

GOOS=darwin GOARCH=arm64 go install github.com/go-delve/delve/cmd/dlv@latest

VSCode users: note that the Go extension's go.toolsGopath is not necessarily the same as $GOBIN (where go install installs binaries). That is, you may still get this error in VSCode (I'm guessing that if GOARCH is exported when you install the extension, this might fix this, but I haven't tested that). I keep the go.toolsGopath and GOBIN separate, but I created a symlink in the go.toolsGopath directory to my $GOBIN/dlv binary so that I can use the same installation from the commandline and within VSCode.

@apgupta3303
Copy link

I have a M1 chip too and have Go 1.15.15 which is only available in amd64. Is there anyway to get rid of this error?

@nhatnd1
Copy link

nhatnd1 commented Jun 22, 2022

I have a M1 chip too and have Go 1.15.15 which is only available in amd64. Is there anyway to get rid of this error?

why don't you use latest version? maybe go 1.15 release before M1 chip

@apgupta3303
Copy link

I need 1.15.15 for what I am working on, so I did not know if there was a different way to get rid of the error

@JiahaoWei-RH
Copy link

If you are a goland user, please check if goland is using the apple version.

@jac6199
Copy link

jac6199 commented Aug 15, 2022

After trying all previous comments, I managed to fix this issue reinstaling delve to the last version (1.8.2) through brew. Be sure to uninstall the last version

This is what worked for me. Thanks to this poster. I ran "go get -u github.com/go-delve/delve/cmd/dlv" in the terminal after installing the ARM version of Go and then it started working.

@JohnTa90
Copy link

JohnTa90 commented Nov 5, 2022

mac m1 芯片的系统,安装 arm架构的go可解决
go 安装包:https://dl.google.com/go/go1.19.3.darwin-arm64.pkg
安装dlv: go install github.com/go-delve/delve/cmd/dlv@latest

@thanhdatvo
Copy link

thanhdatvo commented Nov 7, 2022

I had same problem.
The problem may be because I installed go using both brew and .pkg file
I fixed it by removing usr/local/go then I restarted the vscode
The go debugger works again

@tttmaximttt
Copy link

tttmaximttt commented Mar 5, 2023

So what the solution for this error???

GOROOT=/usr/local/go #gosetup
GOPATH=/Users/----/go #gosetup
/usr/local/go/bin/go build -o /private/var/folders/q0/w8vfk29x1218ds3x_371fylm0000gp/T/GoLand/___go_build_patterns -gcflags all=-N -l patterns #gosetup
/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/mac/dlv --listen=127.0.0.1:55442 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /private/var/folders/q0/w8vfk29x1218ds3x_371fylm0000gp/T/GoLand/___go_build_patterns --
API server listening at: 127.0.0.1:55442
could not launch process: can not run under Rosetta, check that the installed build of Go is right for your CPU architecture

Debugger finished with the exit code 1
 go version 
go version go1.20.1 darwin/arm64
GOOS=darwin GOARCH=arm64 go install github.com/aarzilli/gdlv@latest
GOOS=darwin GOARCH=arm64 go install github.com/go-delve/delve/cmd/dlv@latest
didn't help

removing and reinstalling go, didn't help

@kleinerhund
Copy link

What worked for me was to not install dlv via VS Code, but to manually install the specific version of dlv with the go tool.

In your go directory first remove existing dlv installation.
$ rm dlv

Then install
$ go install github.com/go-delve/delve/cmd/dlv@v1.20.1 (or whatever version you require)

More installation here: https://github.com/go-delve/delve/blob/master/Documentation/installation/README.md

@eatakishiyev
Copy link

eatakishiyev commented Mar 11, 2023

My problem solved by installing go release for ARM64 architecture. After installation , change GOROOT in IDE to new installed one.
https://go.dev/dl/

@JoeFerrucci
Copy link

JoeFerrucci commented Mar 14, 2023

✅ SOLUTION ✅

The issue is that you had installed the non-M1 version of GoLang and/or VSCode.
There are versions for Intel and Apple chips of both Go and VSCode. You need both to be the arm64 (Apple Silicon) version

If you didn't install both GoLang and VSCode using the arm64 distribution then that is where the problem is.

To fix this issue:

  • Completely remove GoLang and VSCode from your system:
    • Remove GoLang completely:
      • sudo rm -rf /usr/local/go
      • sudo rm /etc/paths.d/go
      • sudo rm -rf ~/joe/go (replace joe with your own account name)
        • (removing this is the 🔑 to fixing your issue)
    • Remove VSCode completely:
      • rm -fr ~/Library/Preferences/com.microsoft.VSCode.helper.plist
      • rm -fr ~/Library/Preferences/com.microsoft.VSCode.plist
      • rm -fr ~/Library/Caches/com.microsoft.VSCode
      • rm -fr ~/Library/Caches/com.microsoft.VSCode.ShipIt/
      • rm -fr ~/Library/Application\ Support/Code/
      • rm -fr ~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
      • rm -fr ~/.vscode/
  • Download the arm64 version of each GoLang and VSCode.
  • Install GoLang
  • Install VSCode
  • Open VSCode.
  • Install the Go extension
  • Open a GoLang project/directory.
  • It will ask you to install the Go tools (like 8 or so tools). Just click "Install All"
    Installing 8 tools at /Users/joe/go/bin in module mode.
    gotests
    gomodifytags
    impl
    goplay
    dlv
    staticcheck
    gopls
    go-outline
  • Open a .go file that you want to run.
  • Run it using VS Code.

That's it! You should be good to go now 👍

@freephenix
Copy link

Uninstall Golang(AMD-64 version).

  1. Install Golang(ARM-64). Confirm it with go env GOARCH
  2. Remove(tools that VS-Code uses) binaries from $GOPATH/bin (Important)
  3. Restart your VS-Code and install tools that VS-Code needed(if not installed vscode will complain and will ask you to install them)
    Root cause of the problem: I accidentally installed amd-64 version instead of arm-64 version in my Apple Mac M1.

Thank you, it worked for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests