From d84b6bb8226540f53e74b9da2e24d6cddbe5acda Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Fri, 20 Oct 2017 23:10:55 +0000 Subject: [PATCH] build: Warn when being executed outside of gopath GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4425 --- build.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.go b/build.go index 452ae9c1..8bd2fa67 100644 --- a/build.go +++ b/build.go @@ -45,7 +45,7 @@ var ( noBuildGopath bool extraTags string installSuffix string - pkgdir string + pkgdir string ) type target struct { @@ -204,7 +204,7 @@ func main() { }() } - if gopath() == "" { + if gopath := gopath(); gopath == "" { gopath, err := temporaryBuildDir() if err != nil { log.Fatal(err) @@ -217,6 +217,13 @@ func main() { } os.Setenv("GOPATH", gopath) log.Println("GOPATH is", gopath) + } else { + gopath, _ = filepath.EvalSymlinks(gopath) + wd, _ := os.Getwd() + wd, _ = filepath.EvalSymlinks(wd) + if filepath.Join(gopath, "src/github.com/syncthing/syncthing") != wd { + fmt.Println("You are running this outside of GOPATH/src/github.com/syncthing/syncthing, this might cause failure!") + } } // Set path to $GOPATH/bin:$PATH so that we can for sure find tools we