Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Debugger fails when stepping into standard library with "Unable to open 'server.go'" #1178

Closed
rpfister51 opened this issue Aug 30, 2017 · 4 comments

Comments

@rpfister51
Copy link

While debugging the sample application (github.com/lukehoban/webapp-go/tree/debugging) (I’ve attached a partial screenshot.) The message is “Unable to open ‘server.go’: File not found (c:\Users\rpfister\usr\local\go\src\net\http\server.go).

unable to find server go

This seems to be a mishmash of fragments from the local and container paths.

The local file is here: C:\Go\src\net\http\server.go
The container file is here: /usr/local/go/src/net/http/server.go

But it looked here: c:\Users\rpfister\usr\local\go\src\net\http\server.go, which is home on the local machine (C:\Users\rpfister) added to the remote path (\local\go\src\net\http\server.go) to create a path that doesn't exist anywhere.

Additional info:
The local host’s GOROOT is C:\Go.
The local host's GOPATH is C:\Users\rpfister\go.
The container’s GOROOT is /go.
The container's GOPATH is undefined.

To reproduce

Clone the debugging branch of https://github.com/lukehoban/webapp-go/tree/debugging

Change line 1 of Dockerfile from "FROM golang:1.6" to "FROM golang:1.7" (The docker build fails using golang:1.6.)

Change "host": "192.168.99.100" to "host: "localhost" in line 29 of .vscode/launch.json (assuming you are running on the same machine).

Follow instructions in the comments in the launch.json; i.e., run the following two commands from the command prompt.

$ docker build -t webapp-go .   
$ docker run -d --name webapp-go --privileged -p 8080:8080 -p 2345:2345 webapp-go

Set breakpoint to line 37 in main.go

Launch the "Remote debug in Docker" debug configuration.

Step over repeatedly until the error is encountered.

Versions in use

Delve
PS C:\Users\rpfister> dlv version
Delve Debugger
Version: 1.0.0-rc.1
Build: $Id: b6077a6a35c48a31716aad2ad3fdf77bbdf70abd $
Golang
PS C:\Users\rpfister> go version
go version go1.8.3 windows/amd64
Docker
PS C:\Users\rpfister> docker version
Client:
 Version:      17.06.1-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 22:48:20 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.06.1-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 22:54:55 2017
 OS/Arch:      linux/amd64
 Experimental: true
Visual Studio Code

Visual Studio Code 1.15.1
Commit 41abd21afdf7424c89319dd7cb0445cc6f376959
Date 2017-08-16T18:07:25.676Z
Shell 1.6.6
Renderer 56.0.2924.87
Node 7.4.0
Architecture x64

Go extension (lukehoban.go) 0.6.63, 26th July, 2017

@ramya-rao-a
Copy link
Contributor

I couldn't repro on my Mac
On my Windows machine, I got similar error, but the msg said it was not able to find \usr\local\go\src\net\http\server.go instead.

Since the path has Windows like path separator, my guess was that the issue is with https://github.com/Microsoft/vscode-go/blob/0.6.63/src/debugAdapter/goDebug.ts#L502

Which makes sense because that line of code tries to replace the remote path of the program being debugged with local path. Which works fine as long as the code is under GOPATH

Since the std lib code is under GOROOT and not GOPATH, that line doesn't do anything other than changing / to \

It also makes sense why I didn't have issues in my Mac because the GOROOT is the same in remote and local.

What I don't get is why in your case c:\Users\rpfister gets appended to the remote path to server.go.

Regardless, can you try installing the extension from https://github.com/Microsoft/vscode-go/blob/remote-debug/Go-latest.vsix and see if it makes any difference? That has the fix for the issue I could repro i.e the error message that says cannot find file \usr\local\go\src\net\http\server.go

@rpfister51
Copy link
Author

Hi @ramya-rao-a, it looks like that fixed it! I stepped repeatedly with no errors. I'll mark this as closed. Thanks for your help.

I do have a question. Others where I work are also interested in remote debugging and see these same problems. I assume these changes will at some point in the future be in a mainline version that can be downloaded from the VS Code website. Do you know when that will be or what version that will be?

Thanks again.

@ramya-rao-a
Copy link
Contributor

I would be releasing an update early next week and it should have the current fixes.

ramya-rao-a added a commit that referenced this issue Sep 1, 2017
* Map remote goroot to local goroot #1178

* Updated vsix for testing

* Use path separators when looking for src in path
@ramya-rao-a
Copy link
Contributor

This fix is now out in the latest update to the Go extension 0.6.64

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants