问题
I boot up ubuntu using Vagrant to compile some C code, now i like to debug this code using
Visual Studio Code.
How can i setup some kind of remote debug where the compiler and source code and all on the Ubuntu VM
And I only using VSCode from windows?
PS.
This used to work very well with windows WSL linux .
But now i like to achieve the same result with Ubuntu using Vagrant ( using Virtual Box ).
Can it be done?
UPDATE
I tried as suggested but I'm getting error :
my virtual box config from 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
The error :
[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] ------
回答1:
Yes, as long as you have SSH configured in the VM, you can use the Remote - SSH extension as I detailed in this answer.
来源:https://stackoverflow.com/questions/65709446/debug-c-app-using-visual-studio-code-and-vagrant-runnig-ubuntu