cmd/go: crash during loading in dirAndRoot (vendor-related)
- Dominant language
- Go
- Stars
- 139k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
@samthanawalla encountered this crash while using the web-based VS Code with a Google VM as the backend.

The error indicates a crash propagated via gopls and go/packages up from the go command, specifically the dirAndRoot function:
```
// dirAndRoot returns the source directory and workspace root
// for the package p, guaranteeing that root is a path prefix of dir.
func dirAndRoot(path string, dir, root string) (string, string) {
origDir, origRoot := dir, root
dir = filepath.Clean(dir)
root = filepath.Join(root, "src")
if !str.HasFilePathPrefix(dir, root) || path != "command-line-arguments" && filepath.Join(root, path) != dir {
// Look for symlinks before reporting error.
dir = expandPath(dir)
root = expandPath(root)
}
if !str.HasFilePathPrefix(dir, root) || len(dir) <= len(root) || dir[len(root)] != filepath.Separator || path != "command-line-arguments" && !build.IsLocalImport(path) && filepath.Join(root, path) != dir {
debug.PrintStack()
base.Fatalf("unexpected directory layout:\n"+
" import path: %s\n"+
" root: %s\n"+
" dir: %s\n"+
" expand root: %s\n"+
" expand dir: %s\n"+
" separator: %s",
path,
filepath.Join(origRoot, "src"),
filepath.Clean(origDir),
origRoot,
origDir,
string(filepath.Separator))
}
return dir, root
}
```
In addition the VS Code UI showed this truncated error:
```
Failed to run "go env env, -json, GOMOD": Command failed: /usr/lib/go...
```
Sorry there's not much to go on yet. I wonder whether the remote machine has as GOPACKAGESDRIVER env var (or $PATH executable).
Contributor guide
Assessment
This issue has not been assessed yet.