dlv-dap fails to install for Go in VS Code on Windows for because of a malformed path

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

dlv-dap fails to install for Go in VS Code on Windows for because of a malformed path

问题

我正在尝试在运行Windows Server 2019的虚拟机中启动VSCode,以便调试特定于Windows的Go程序,但是当我尝试编译时,VSCode要求安装工具,但安装dlv-dap失败,尽管其他工具安装成功。(我对VSCode还不熟悉,并且在过去的10年里几乎没有使用过Windows,但我已经在macOS上使用Go进行编程多年了。)

从输出中可以看到问题是go.exe路径中的bin重复了,例如:

C:\\Users\\Administrator\\go\\bin\\bin\\go.exe

我已经重新安装了Go和VSCode,我已经移动了GOPATH和GOROOT,我已经尝试不使用GOPATH和GOROOT,我已经将GOPATH和GOROOT添加到settings.json文件中,但始终出现相同的问题。

这让我认为这是一个错误,但在向GitHub提交错误之前,我想确保这不是我做了一些愚蠢的事情,因为他们在错误提交的指南中建议这样做。

对于这个输出,我在我的用户环境中有以下设置:

  • 我的GOROOTC:\Users\Administrator\go\bin
  • 我的GOPATHC:\Users\Administrator\go

我还通过命令行在VSCode之外安装了dlv-dap,但VSCode没有识别到我已经这样做。

有任何想法我可能做错了什么吗?

另外,我应该在哪里查找运行此安装的源代码,以确定是否存在错误,并在出现错误时提交拉取请求进行修复?

提前感谢您提供的任何帮助。

Tools environment: GOPATH=C:\Users\Administrator\go
Installing 8 tools at C:\Users\Administrator\go\bin in module mode.
  gopkgs
  gotests
  gomodifytags
  impl
  goplay
  dlv
  dlv-dap
  staticcheck

Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest (C:\Users\Administrator\go\bin\gopkgs.exe) 成功安装
Installing github.com/cweill/gotests/gotests@latest (C:\Users\Administrator\go\bin\gotests.exe) 成功安装
Installing github.com/fatih/gomodifytags@latest (C:\Users\Administrator\go\bin\gomodifytags.exe) 成功安装
Installing github.com/josharian/impl@latest (C:\Users\Administrator\go\bin\impl.exe) 成功安装
Installing github.com/haya14busa/goplay/cmd/goplay@latest (C:\Users\Administrator\go\bin\goplay.exe) 成功安装
Installing github.com/go-delve/delve/cmd/dlv@latest (C:\Users\Administrator\go\bin\dlv.exe) 成功安装
Installing github.com/go-delve/delve/cmd/dlv@2f13672765fe 安装失败
{
 "errno": -4058,
 "code": "ENOENT",
 "syscall": "spawn C:\\Users\\Administrator\\go\\bin\\bin\\go.exe",
 "path": "C:\\Users\\Administrator\\go\\bin\\bin\\go.exe",
 "spawnargs": [
  "get",
  "-x",
  "-d",
  "github.com/go-delve/delve/cmd/dlv@2f13672765fe"
 ],
 "cmd": "C:\\Users\\Administrator\\go\\bin\\bin\\go.exe get -x -d github.com/go-delve/delve/cmd/dlv@2f13672765fe",
 "stdout": "",
 "stderr": ""
}
Installing honnef.co/go/tools/cmd/staticcheck@latest (C:\Users\Administrator\go\bin\staticcheck.exe) 成功安装

有1个工具安装失败。

dlv-dap: failed to install dlv-dap(github.com/go-delve/delve/cmd/dlv@2f13672765fe): Error: spawn C:\Users\Administrator\go\bin\bin\go.exe ENOENT 
'C:\Users\Administrator\go\bin\go.exe env': warning: GOPATH set to GOROOT (C:\Users\Administrator\go) has no effect


英文:

I am trying to get up VSCode in a virtual machine running Windows Server 2019 to allow debugging Windows-specific Go programs but when I try to compile and VSCode asks to install the tools it fails to install dlv-dap although installs the other tools fine. (I am new to VSCode and have not really used Windows in over 10 years, but have programmed for decades and in Go on macOS for several years now.)

The problem as you can see from the output is that bin has been duplicated in the go.exe path, e.g.:

C:\\Users\\Administrator\\go\\bin\\bin\\go.exe

I have reinstalled Go and reinstalled VSCode, I have moved around GOPATH and GOROOT, I have tried doing without GOPATH and GOROOT, I have added GOPATH and GOROOT to the settings.json file, and always the same problem.

This leads me to think this is a bug, but I wanted to make sure that it wasn't me doing something stupid before I reported it on GitHub, as they suggest in their directions for bug submission.

For this output I have these setting in my User environment:

  • My GOROOT is C:\Users\Administrator\go\bin
  • My GOPATH is C:\Users\Administrator\go

I also installed dlv-dap via command line outside of VSCode, but VSCode did not recognize that I had done so.

Any ideas what I might be doing wrong?

Also, where would I look for the source code that runs this install to see if I can determine if there is an error and if an error submit a pull request fixing it?

Thanks in advance for any help you might provide.

Tools environment: GOPATH=C:\Users\Administrator\go
Installing 8 tools at C:\Users\Administrator\go\bin in module mode.
  gopkgs
  gotests
  gomodifytags
  impl
  goplay
  dlv
  dlv-dap
  staticcheck

Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest (C:\Users\Administrator\go\bin\gopkgs.exe) SUCCEEDED
Installing github.com/cweill/gotests/gotests@latest (C:\Users\Administrator\go\bin\gotests.exe) SUCCEEDED
Installing github.com/fatih/gomodifytags@latest (C:\Users\Administrator\go\bin\gomodifytags.exe) SUCCEEDED
Installing github.com/josharian/impl@latest (C:\Users\Administrator\go\bin\impl.exe) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@latest (C:\Users\Administrator\go\bin\goplay.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (C:\Users\Administrator\go\bin\dlv.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@2f13672765fe FAILED
{
 "errno": -4058,
 "code": "ENOENT",
 "syscall": "spawn C:\\Users\\Administrator\\go\\bin\\bin\\go.exe",
 "path": "C:\\Users\\Administrator\\go\\bin\\bin\\go.exe",
 "spawnargs": [
  "get",
  "-x",
  "-d",
  "github.com/go-delve/delve/cmd/dlv@2f13672765fe"
 ],
 "cmd": "C:\\Users\\Administrator\\go\\bin\\bin\\go.exe get -x -d github.com/go-delve/delve/cmd/dlv@2f13672765fe",
 "stdout": "",
 "stderr": ""
}
Installing honnef.co/go/tools/cmd/staticcheck@latest (C:\Users\Administrator\go\bin\staticcheck.exe) SUCCEEDED

1 tools failed to install.

dlv-dap: failed to install dlv-dap(github.com/go-delve/delve/cmd/dlv@2f13672765fe): Error: spawn C:\Users\Administrator\go\bin\bin\go.exe ENOENT 
'C:\Users\Administrator\go\bin\go.exe env': warning: GOPATH set to GOROOT (C:\Users\Administrator\go) has no effect


答案1

得分: 1

在所有这些操作之后,我从settings.json中移除了go.gorootgo.delveConfig,然后它成功安装并开始工作了。(我之前在尝试调试问题时添加了这些内容。)

这是我从settings.json中移除的内容:

"go.goroot": "C:\Users\Administrator\go\bin",
"go.delveConfig": {
    "debugAdapter": "legacy",
}

我不知道这是否"修复"了问题,或者我做的其他操作修复了问题,而这只是剩下的垃圾,但无论如何,现在它可以正常工作了,希望这对其他遇到相同问题的人有所帮助。

英文:

And after all that, I removed go.goroot and go.delveConfig from settings.json, and it installed fine and just started working. (I had added those earlier while trying to debug the problem.)

This is what I removed from settings.json:

"go.goroot": "C:\Users\Administrator\go\bin",
"go.delveConfig": {
    "debugAdapter": "legacy",
}

I don't know if that "fixed" it, or if something else I did fixed it and that was just leftover cruft, but either way it is working now and hopefully this helps someone else that runs into the same issue.

huangapple
  • 本文由 发表于 2021年12月27日 20:22:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/70495456.html
匿名

发表评论

匿名网友

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

确定