-
Notifications
You must be signed in to change notification settings - Fork 819
When I build a binary in a subdirectory, build error links are not valid/clickable #3068
-
Hello, I have the following launch config:
{ "version": "0.2.0", "configurations": [ { "name": "Service", "type": "go", "request": "launch", "mode": "auto", "program": "cmd/controller", "cwd": "${workspaceFolder}" } ] }
Now, when I launch it Delve changes directory into cmd/controller and builds .
and while this works the problem is then when I get compilation error, links are not valid. For example:
Starting: /home/lzap/go/bin/dlv dap --listen=127.0.0.1:41945 --log-dest=3 from /home/lzap/forester/cmd/controller
DAP server listening at: 127.0.0.1:41945
Build Error: go build -o /home/lzap/forester/cmd/controller/__debug_bin3829863487 -gcflags all=-N -l .
# forester/internal/config
../../internal/config/config.go:121:37: undefined: Hostname (exit status 1)
When I click on ../../internal/config/config.go:121:37
VSCode is unable to locate this file as it tries to find it two levels above the project directory.
I must be missing something, what is the correct launch configuration for this single Go application setup which is I believe pretty common use case. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions
The go build
invocation is controlled by delve, not vscode-go. If delve supports a flag or other configuration option to change this behavior, please open a vscode-go feature request to add support for that (if we don't already support it). If delve does not have any such option, then this is a delve issue/request, not a vscode-go one.
When I click on
../../internal/config/config.go:121:37
VSCode is unable to locate this file as it tries to find it two levels above the project directory.
This is a separate issue. Is it fair to say your actual issue is, "When I build a binary in a subdirectory, build error links are not valid/clickable"? If so, then that is potentially a bug that should ...
Replies: 2 comments 4 replies
-
Have the same issue, unable to find solution for this.
As cwd
param defined here
Workspace relative or absolute path to the working directory of the program being debugged if a non-empty value is specified. The program folder is used as the working directory if cwd is omitted or empty.(Default: "")
As far as I can tell, resulting binary is executed from cwd
. Yet go build
is not.
Beta Was this translation helpful? Give feedback.
All reactions
-
This seems like the expected behavior to me.
Beta Was this translation helpful? Give feedback.
All reactions
-
The go build
invocation is controlled by delve, not vscode-go. If delve supports a flag or other configuration option to change this behavior, please open a vscode-go feature request to add support for that (if we don't already support it). If delve does not have any such option, then this is a delve issue/request, not a vscode-go one.
When I click on
../../internal/config/config.go:121:37
VSCode is unable to locate this file as it tries to find it two levels above the project directory.
This is a separate issue. Is it fair to say your actual issue is, "When I build a binary in a subdirectory, build error links are not valid/clickable"? If so, then that is potentially a bug that should be fixed and IMO changing the working directory that delve uses for invoking go build
is not the solution.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for the analysis, I have renamed the discussion to "When I build a binary in a subdirectory, build error links are not valid/clickable". Shall I create an issue? In which project tho, I am a bit confused here on how this works.
Beta Was this translation helpful? Give feedback.
All reactions
-
Create an issue in vscode-go. Ideally we could handle this by making a change to vscode-go. It's possible that won't work, but we should investigate first. If you ping me in the issue I'll try to take a look, though I'm a volunteer contributor so I may not have time.
Beta Was this translation helpful? Give feedback.
All reactions
-
Created an issue, thanks: #3771
Beta Was this translation helpful? Give feedback.