如何修复VSCode中的VSCode调试器问题?

huangapple go评论82阅读模式
英文:

How can I fix the vscode debuger in VSCode?

问题

我正在尝试使用dvl-dap在VSCode中调试一段简单的Golang代码,但是我遇到了以下错误:

如何修复VSCode中的VSCode调试器问题?

有人知道如何解决这个问题吗?

我是通过Remote - SSH扩展从远程虚拟机上工作的。

英文:

I'm trying to debug a simple Golang code in VSCode with dvl-dap and I get the following error:

如何修复VSCode中的VSCode调试器问题?

Does anybody know how can I solved this issue?

I'm working from a remote vm using the extension Remote - SSH.

答案1

得分: 5

我正在为你翻译以下内容:

我正在添加这个作为参考,以防其他人遇到这个问题。

修复已经合并/发布在v1.7.1上,但我正在远程调试v1.8.3,仍然遇到这个问题。

一个可能的解决方法是在你的VSCode的settings.json中禁用“同一用户”检查,像这样:

go.delveConfig": {
    "debugAdapter": "dlv-dap",
    "dlvFlags": ["--only-same-user=false"],
    [...]
}

然后让VSCode使用默认的launch.json来远程运行delve并连接到你的本地客户端--在我测试过的项目中,我甚至没有定义一个自定义的launch.json。

英文:

I'm adding this for reference in case someone else faces this issue.

The fix was merged/released on v1.7.1, but I'm remote debugging on v1.8.3 and still hitting that problem.

One possible workaround is to disable the 'same user' check in your VSCode settings.json, like this

go.delveConfig": {
    "debugAdapter": "dlv-dap",
    "dlvFlags": ["--only-same-user=false"],
    [...]
}

and then just let VSCode use a default launch.json to run delve remotely and attach your local client -- in the project where I've tested this I haven't even defined a custom launch.json.

答案2

得分: 0

这最初是在golang/vscode-go问题1555中报告的:

>> accepted connection from client
-> server: {"type":"request","seq":1,"command":"initialize","arguments":{"adapterID":"go","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path"}}
<- server: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"DAP server listening at: 127.0.0.1:40535\n2021-06-09T02:26:51Z debug layer=dap DAP server pid = 12574\n"}}
<- server: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"2021/06/09 02:26:51 sameuser_linux.go:114: closing connection from different user (127.0.0.1:52544): connections to localhost are only accepted from the same UNIX user for security reasons\n"}}
<- server: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"2021-06-09T02:26:51Z error layer=dap Error accepting client connection: Only connections from the same user that started this instance of Delve are allowed to connect. See --only-same-user.\n2021-06-09T02:26:51Z debug layer=dap DAP server stopping...\n2021-06-09T02:26:51Z debug layer=dap DAP server stopped\n"}}
<- server: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"connection error: Error: read ECONNRESET\n"}}
<- server: {"seq":0,"type":"event","event":"terminated"}

主要错误信息为:

sameuser_linux.go:114: closing connection from different user (127.0.0.1:52544):
connections to localhost are only accepted from the same UNIX user for security reasons

它在delve的一个分支中修复了:suzmue/delve提交5137515,但该补丁可能尚未集成到go-delve/delve中:其CHANGELOG尚未列出"service: fix sameuser check"。
不过,请确保您正在使用最新的delve 1.7.2。

英文:

That was reported initially in golang/vscode-go issue 1555:

&gt;&gt; accepted connection from client
-&gt; server: {&quot;type&quot;:&quot;request&quot;,&quot;seq&quot;:1,&quot;command&quot;:&quot;initialize&quot;,&quot;arguments&quot;:{&quot;adapterID&quot;:&quot;go&quot;,&quot;linesStartAt1&quot;:true,&quot;columnsStartAt1&quot;:true,&quot;pathFormat&quot;:&quot;path&quot;}}
&lt;- server: {&quot;seq&quot;:0,&quot;type&quot;:&quot;event&quot;,&quot;event&quot;:&quot;output&quot;,&quot;body&quot;:{&quot;category&quot;:&quot;console&quot;,&quot;output&quot;:&quot;DAP server listening at: 127.0.0.1:40535\n2021-06-09T02:26:51Z debug layer=dap DAP server pid = 12574\n&quot;}}
&lt;- server: {&quot;seq&quot;:0,&quot;type&quot;:&quot;event&quot;,&quot;event&quot;:&quot;output&quot;,&quot;body&quot;:{&quot;category&quot;:&quot;stderr&quot;,&quot;output&quot;:&quot;2021/06/09 02:26:51 sameuser_linux.go:114: closing connection from different user (127.0.0.1:52544): connections to localhost are only accepted from the same UNIX user for security reasons\n&quot;}}
&lt;- server: {&quot;seq&quot;:0,&quot;type&quot;:&quot;event&quot;,&quot;event&quot;:&quot;output&quot;,&quot;body&quot;:{&quot;category&quot;:&quot;console&quot;,&quot;output&quot;:&quot;2021-06-09T02:26:51Z error layer=dap Error accepting client connection: Only connections from the same user that started this instance of Delve are allowed to connect. See --only-same-user.\n2021-06-09T02:26:51Z debug layer=dap DAP server stopping...\n2021-06-09T02:26:51Z debug layer=dap DAP server stopped\n&quot;}}
&lt;- server: {&quot;seq&quot;:0,&quot;type&quot;:&quot;event&quot;,&quot;event&quot;:&quot;output&quot;,&quot;body&quot;:{&quot;category&quot;:&quot;console&quot;,&quot;output&quot;:&quot;connection error: Error: read ECONNRESET\n&quot;}}
&lt;- server: {&quot;seq&quot;:0,&quot;type&quot;:&quot;event&quot;,&quot;event&quot;:&quot;terminated&quot;}

With the main error message being:

sameuser_linux.go:114: closing connection from different user (127.0.0.1:52544):
connections to localhost are only accepted from the same UNIX user for security reasons

It is fixed in a fork of delve: suzmue/delve commit 5137515, but said patch might not have been yet integrated to go-delve/delve: its CHANGELOG does not yet list "service: fix sameuser check".
Still, make sure you are using the latest delve 1.7.2.

huangapple
  • 本文由 发表于 2021年10月5日 05:51:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/69442767.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定