I would like to be able to debug through Geth's Go code - using Intellij Webstorm.

Ideally, I would like to run a, private, Geth node inside of Webstorm and set a breakpoint, but I would also settle for remotely connecting to a local node that I have started from the command line.

It looks to me as if the entry point for Geth is main.go, however, when I try to run this I get the following errors:

# command-line-arguments
cmd/geth/main.go:112: undefined: configFileFlag
cmd/geth/main.go:143: undefined: initCommand
cmd/geth/main.go:144: undefined: importCommand
cmd/geth/main.go:145: undefined: exportCommand
cmd/geth/main.go:146: undefined: removedbCommand
cmd/geth/main.go:147: undefined: dumpCommand
cmd/geth/main.go:149: undefined: monitorCommand
cmd/geth/main.go:151: undefined: accountCommand
cmd/geth/main.go:152: undefined: walletCommand
cmd/geth/main.go:154: undefined: consoleCommand
cmd/geth/main.go:154: too many errors

Is someone able to help me with exactly how I can start Geth from within Webstorm i.e. not from the compiled, geth, binary, please?

--- Update after trying to run from the package instead of a file ---

Unfortunately, when I set the package to "github.com/ethereum/go-ethereum/cmd/geth" I get the following errors:

/usr/local/go/bin/go build "-ldflags=-linkmode internal" -o /tmp/___main_go github.com/ethereum/go-ethereum/cmd/geth

# github.com/ethereum/go-ethereum/cmd/geth

github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid(.text): relocation target __pthread_unwind_next not defined

github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid(.text): undefined: "__pthread_unwind_next"
  • its look like you didnt go get the dependencies – MIkCode Oct 2 '17 at 10:51
  • did you solve it? I also have the same problem. I am compiling with go compiler tough, the standard one. It can't find config file and other variables are not set, exactly as you do. I am running with go run ... geth.go. Did you found out how to remove those errors? – Nulik Oct 7 '17 at 9:25
  • Yes, I've managed to solve the problem. I noticed that I wasn't on Go 1.9 and after I updated to the latest version of Go the errors went away. – SteveJaxon Oct 9 '17 at 9:13

First make sure you have the latest version, EAP 15, 173.2696.28, and you are using the latest version of Go, 1.9, as that's preferred for a better debugging experience due to the recent improvements in Go with regards to debugging.

Then, go to Run | Edit Configurations | Go Applications | select the run configuration you want to edit | Run kind and change it to File from Package. Then type the name of the package, for example, github.com/ethereum/go-ethereum/cmd/geth and save the settings. Then go to Run | Debug... and select the run configuration you've edited previously and select that as a debug run.

I've also created a small video which should guide you on how to change the Run kind for a Run Configuration, you can see it here.

  • Thanks for providing a video to help explain - it really helped to clarify what you meant. Unfortunately, it didn't seem to solve the problem - I've added more details in the update to my question. – SteveJaxon Oct 3 '17 at 17:34
  • You can omit the -linkmode in your case, that's useful mostly on Windows and Go < 1.9. In some cases it works on Linux / OSX it helps with the debugging as well but in this case it can be omitted. Remove that and try again. – dlsniper Oct 3 '17 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.