Skip to content

Commit

Permalink
Merge #24391
Browse files Browse the repository at this point in the history
24391: Makefile: further improve GOPATH detection r=RaduBerinde a=benesch

Squash of #24387.

Closes #24387.

---

It is necessary to use `realpath` to get the real GOPATH, as symlinks
may be in play. For instance, on FreeBSD `/home` is symlinked to
`/usr/home/`, but the former is often used. If `realpath` isn't used,
the string-based prefix matching will incorrectly claim that CWD is not
a child of GOPATH.

Additionally, if `go env GOPATH` does not return a workable value, that
means there is something wrong with the golang deployment and it is
unsafe to assume the value of GOPATH and attempt to proceed. Error out
with a message about GOPATH resolution if `go env GOPATH` does not come
back with a good value.

Release note (build change): None
  • Loading branch information
craig[bot] committed Apr 1, 2018
2 parents d75d2a1 + 6380794 commit 156c3a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ UI_ROOT := $(PKG_ROOT)/ui
SQLPARSER_ROOT := $(PKG_ROOT)/sql/parser

# Ensure we have an unambiguous GOPATH.
GOPATH := $(shell $(GO) env GOPATH)
GOPATH := $(realpath $(shell $(GO) env GOPATH))
ifeq ($(strip $(GOPATH)),)
$(error GOPATH is not set and could not be automatically determined, build cannot continue)
endif

ifneq "$(or $(findstring :,$(GOPATH)),$(findstring ;,$(GOPATH)))" ""
$(error GOPATHs with multiple entries are not supported)
Expand Down

0 comments on commit 156c3a4

Please sign in to comment.