Issue
When trying to debug go application I get the following similar error messages.
I initially tried debugging simple golang program with the following vscode launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}"
}
]
}
What I get is:
could not launch process: fork/exec /tmp/__debug_bin1874603807: operation not permitted
Setting "debugAdapter": "legacy"
leads to similar result:
could not launch process: fork/exec /home/user/test/__debug_bin: operation not permitted
Starting dlv from command line has same output:
user@my-machine:~/test$ /home/user/go/bin/dlv debug could not launch process: fork/exec /home/user/test/__debug_bin: operation not permitted
I have tested that running files from /tmp is allowed; I have tried setting kernel.yama.ptrace_scope = 0
in /etc/sysctl.d/10-ptrace.conf
because all I can find on this error is related to ptrace (https://github.com/go-delve/delve/issues/515).
Also it is worth mentioning that command works as root:
user@my-machine:~/test$ su root
Password:
root@my-machine:/home/user/test# export PATH=$PATH:/usr/local/go/bin
root@my-machine:/home/user/test# go version
go version go1.17.6 linux/amd64
root@my-machine:/home/user/test# ../go/bin/dlv debug
Type 'help' for list of commands.
(dlv) quit
Reinstalling dlv with deleting dlv binary and running go install github.com/go-delve/delve/cmd/dlv@latest
does not help. I have a fresh Ubuntu Server 20.04 installation.
How to fix debugging?
Solution
I have figured out that setting kernel.yama.ptrace_scope = 0
did not work for some reason, however echo 0 > /proc/sys/kernel/yama/ptrace_scope
helped
Answered By - StrangeMann Answer Checked By - Gilberto Lyons (WPSolving Admin)