-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Further improve GOPATH detection in Makefile #24387
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,7 +201,11 @@ UI_ROOT := $(PKG_ROOT)/ui | |
SQLPARSER_ROOT := $(PKG_ROOT)/sql/parser | ||
|
||
# Ensure we have an unambiguous GOPATH. | ||
GOPATH := $(shell $(GO) env GOPATH) | ||
GOPATH := $(shell readlink -f $(shell $(GO) env GOPATH)) | ||
# GOPATH need not be explicitly set if it is the default $HOME/go | ||
ifeq ($(strip $(GOPATH)),) | ||
GOPATH := $(shell readlink -f $$HOME/go) | ||
endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I can't reproduce the need for this.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mqudsi@mysql ~/g/s/g/c/cockroach> go version
go version go1.10.1 freebsd/amd64
mqudsi@mysql ~/g/s/g/c/cockroach> set -e GOPATH; go env GOPATH
mqudsi@mysql ~/g/s/g/c/cockroach> env GOPATH="" go env GOPATH There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, on another machine: mqudsi@freebsd ~/g/s/g/c/cockroach> go version
go version go1.10.1 freebsd/amd64
mqudsi@freebsd ~/g/s/g/c/cockroach> env GOPATH="" go env GOPATH
/home/mqudsi/go Not sure what to make of this. A golang bug, perhaps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check this out:
Seems like maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I've come up with another way of causing this situation:
Does that perhaps describe your situation? If not, could you post the full output of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You nailed it. GOPATH and GOROOT can't both be the same, so that breaks the auto-generation of GOPATH. I guess the best thing here is to error out if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer not to commit this workaround yet. I think it's papering over something more serious. |
||
|
||
ifneq "$(or $(findstring :,$(GOPATH)),$(findstring ;,$(GOPATH)))" "" | ||
$(error GOPATHs with multiple entries are not supported) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this won't work on macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make's built-in
realpath
function might do what you need, though: https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.htmlThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bmake guy, so thanks for pointing me in the right direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benesch regarding CURDIR, I meant that the value of the two variables compared here:
may differ in "symlinkage" while pointing to the same (with possibly either one using the symlink'd
$HOME
value).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. It appears that $(CURDIR) has internally been set to the equivalent of
$(realpath $(shell pwd))
.