Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 6b6c862

Browse files
committed
Autobuilder: Use fully resolved path for GOPATH
Otherwise on systems where /tmp is a symlink (e.g. default OSX setup), GOPATH does not match the current working directory after os.Chdir'ing to that directory (os.Chdir resolves symlinks, unlike a shell's 'cd' command), which causes `dep` to fail complaining that it is being run from outside GOPATH.
1 parent e871061 commit 6b6c862

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,15 @@ func main() {
350350
}
351351

352352
// create a new folder which we will add to GOPATH below
353-
root := filepath.Join(srcdir, "root")
353+
// Note we evaluate all symlinks here for consistency: otherwise os.Chdir below
354+
// will follow links but other references to the path may not, which can lead to
355+
// disagreements between GOPATH and the working directory.
356+
realSrc, err := filepath.EvalSymlinks(srcdir)
357+
if err != nil {
358+
log.Fatalf("Failed to evaluate symlinks in %s: %s\n", srcdir, err.Error())
359+
}
360+
361+
root := filepath.Join(realSrc, "root")
354362

355363
// move source files to where Go expects them to be
356364
newdir := filepath.Join(root, "src", importpath)

0 commit comments

Comments
 (0)