56

I'm trying to get pprof working with Golang.

--text seems to work fine but most of other options does not work.

For instance with pdf:

root@ubuntu:/home/user/IdeaProjects/go_projects/src# go tool pprof --pdf ./src /tmp/profile578584736/cpu.pprof > out.pdf
sh: 1: dot: not found
root@ubuntu:/home/user/IdeaProjects/go_projects/src# 

With gv:

root@ubuntu:/home/user/IdeaProjects/go_projects/src# go tool pprof --gv ./src /tmp/profile578584736/cpu.pprof 
sh: 1: dot: not found
gv -scale 0
Can't exec "gv": No such file or directory at /usr/local/go/pkg/tool/linux_386/pprof line 719.
root@ubuntu:/home/user/IdeaProjects/go_projects/src# 

Is there something that I need to change in Go to get it working?

4 Answers 4

105

For anyone on a Mac using homebrew that comes across this question:

brew install graphviz
0
69

You need dot and gv installed. I see you're using Ubuntu, just try apt-get install graphviz gv

1
  • 1
    Great! Thanks. But also when I go to interactive mode my gv doesn't work (pprof) gv Total: 189 samples gv -scale 0 (pprof) sh: 1: gv: not found Do I need to install gv aswell? Commented Oct 6, 2014 at 13:00
1

Got a similar error on Windows 10. I fixed it by installing graphviz from here https://graphviz.org/download/. After that I restarted my IDE, issued the pdf and png commands and everything worked

1
  • Just make sure to "check" the box containing "add path to your system for all user" while installing Commented Oct 19, 2022 at 10:52
0

An alternative option for Ubuntu

$ sudo apt install graphviz

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