-
Notifications
You must be signed in to change notification settings - Fork 645
How to debug Go project located on remote linux server? #2242
Comments
I have the same question about how to debug on the remote machine, the "remotePath" and "program" can only find the local path in stead of the remote machine path, otherwise you will get the "Failed to conitnue" error.
and the dlv command (running on the remote machine):
get the message in the remote machine output:
|
I'm currently having issues with this as well, but I found the following related issues that contain some further info: |
For the I have some questions of myself too. |
You mean that I must have the same project files on my local windows desktop and on the remote Ubuntu server? |
You are right, you have to put the same project files in both sides, and set the correct path of your windows desktop and the remote server as following example:
|
The above answer is correct so I'm going to close this issue. Please ping if you have further questions. |
@jhendrixMSFT: I think the question by @wcsiu wasn't answered yet:
(From #2242 (comment)) |
Proper support for modules is still a work-in-progress. @wcsiu have you tried the Go language server? Please see https://github.com/microsoft/vscode-go/wiki/Go-modules-support-in-Visual-Studio-Code for info on how to enable it. If there are specific debugger issues WRT modules I suggest opening a new issue (or issues) so we can track each bug. |
I have some Golang project (simple 'hello' application) on remote Ubuntu server. It is located in '/home/user/go/src/hello' directory. The only project file is 'hello.go':
I have installed Go tools and Delve dubugger on server. The project compiled and run succesfully.
In terminal I go to the directory '/home/user/go/src/hello' and run delve server in 'headless' mode:
Then I see the message in terminal:
As I understand the debug server has started and ready to work.
I want to debug the remote project from my Windows desktop where VSCode is installed.
So my first question is: What is correct way to open remote sources in VSCode?
I know about 'Remote VSCode' extension which works via SSH. But I didn't want to mess about installing 'rmate', creating SSH tunnel and so on.
There is a SFTP server on my Ubuntu machine. So I used 'Remote Workspace' extension which can work via SFTP. I created special 'code-workspace' file used by this extension to access the remote directory '/home/user/go/src/hello'. Then I open this file in VSCode via 'File --> Open Workspace' menu. Now I can see my remote directory in VSCode Explorer and I can edit my remote 'hello.go' file.
My second question is: How to configure 'launch.json'?
I have created configuration:
What should I set up for 'remotePath' and 'program' attributes?
I tried various combinations. Such as: "${workspaceRoot}/hello" and "/home/user/go/src/hello".
For example I set the following attributes:
Then I set breakpoint at line ' fmt.Println("Hello, world")' and press "Start Debugging" button.
I see that the remote delve server somehow reacts and displays the following message in remote terminal:
But in VSCode I get the error message like this:
"Failed to continue: The program attribute must point to valid directory, .go file or executable."
And in the VSCode Debug Console I get the message:
The program "\home\user\go\src\hello/hello/hello.go" does not exist: Error: ENOENT: no such file or directory, lstat 'C:\home\user\go\src\hello\hello\hello.go'
As I understand VSCode tries to look for source file on my desktop machine (not remote server).
What is correct way to solve my task?
The text was updated successfully, but these errors were encountered: