【问题标题】:Debug C app using visual studio code and Vagrant runnig ubuntu使用 Visual Studio 代码和 Vagrant runnig ubuntu 调试 C 应用程序
【发布时间】:2021-01-13 20:38:55
【问题描述】:

我使用 Vagrant 启动 ubuntu 来编译一些 C 代码,现在我喜欢使用 Visual Studio 代码。
我如何设置某种远程调试,其中编译器和源代码以及所有都在 Ubuntu VM
而且我只使用 Windows 中的 VSCode?
PS.
这曾经在 windows WSL linux 上运行得很好。
但现在我喜欢使用 Vagrant(使用 Virtual Box)在 Ubuntu 上实现相同的结果。 可以做到吗? 更新 我按照建议尝试了,但出现错误:

我的来自 vscode 的虚拟盒子配置:

Host 127.0.0.1:2222
  HostName 127.0.0.1:2222
  IdentityFile c:/HashiCorp/ubuntu-20.04/.vagrant/machines/default/virtualbox/private_key
  User vagrant

错误:

[13:27:45.945] "install" terminal command done
[13:27:45.945] Install terminal quit with output: The process tried to write to a nonexistent pipe.
[13:27:45.945] Received install output: The process tried to write to a nonexistent pipe.
[13:27:45.950] Resolver error: Error: The process tried to write to a nonexistent pipe
    at Function.Offline (c:\Users\foo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.62.0\out\extension.js:1:64330)
    at c:\Users\foo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.62.0\out\extension.js:1:59961
    at Object.t.handleInstallOutput (c:\Users\foo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.62.0\out\extension.js:1:60339)
    at I (c:\Users\foo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.62.0\out\extension.js:1:311112)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async c:\Users\foo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.62.0\out\extension.js:1:309029
    at async Object.t.withShowDetailsEvent (c:\Users\foo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.62.0\out\extension.js:1:403706)
    at async Object.t.resolve (c:\Users\foo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.62.0\out\extension.js:1:312426)
    at async c:\Users\foo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.62.0\out\extension.js:127:110280
[13:27:45.954] ------

【问题讨论】:

  • 是 OpenSSH for Windows installed(或采用相同参数的“兼容”SSH 客户端)吗?您可以使用该客户端从 PowerShell 或 cmd 成功 ssh 到 VM 吗?
  • 另外,请查看this answer 以解决与您遇到的错误非常相似的错误。

标签: debugging visual-studio-code vagrant virtual-machine remote-debugging


【解决方案1】:

是的,只要你在 VM 中配置了 SSH,你就可以使用我在 this answer 中详述的 Remote - SSH 扩展。

【讨论】:

  • 我用我遇到的错误更新了我的问题
猜你喜欢
  • 2018-06-20
  • 1970-01-01
  • 2019-06-11
  • 1970-01-01
  • 2013-06-23
  • 2018-07-27
  • 2016-10-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多