Skip to content
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

clean.bash: GOBIN should be unset #36659

Closed
perillo opened this issue Jan 20, 2020 · 9 comments
Closed

clean.bash: GOBIN should be unset #36659

perillo opened this issue Jan 20, 2020 · 9 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@perillo
Copy link
Contributor

perillo commented Jan 20, 2020

This issue is the same as the one reported in #14340.

In the Go git repository I was trying to clean all the artifacts generate by a previous make.bash, but the command failed since it tried to search the go binary in my $GOBIN.

GOBIN should be unset, and gobin should probably be redefined as

gobin="${GOROOT_FINAL:-..}/bin"
@nikson
Copy link
Contributor

nikson commented Jan 21, 2020

If GOBIN is previously set in env, clean.bash uses the env value.

Because bash {param:-default} only set a value when the parameter is unset or null.

The following change will resolve the issue:

-gobin="${GOBIN:-../bin}"
+gobin="${GOROOT}"/bin

@gopherbot
Copy link

Change https://golang.org/cl/215478 mentions this issue: build: set GOBIN during clean

@perillo
Copy link
Contributor Author

perillo commented Jan 21, 2020

@nikson I think using GOROOT is wrong.

What happens if in $GOROOT (/usr/lib/go on my Linux distribution) there is go 1.13.x and I'm trying to build go 1.20.x?

clean.bash (and probably also clean.rc) should use the newly built go binary.

@toothrot toothrot added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jan 21, 2020
@toothrot toothrot added this to the Backlog milestone Jan 21, 2020
@nikson
Copy link
Contributor

nikson commented Jan 21, 2020

@perillo clean.bash sets $GOROOT to the src root, thus the proposed change will use the newly built binaries.

@perillo
Copy link
Contributor Author

perillo commented Jan 21, 2020

@nikson, you are right sorry. I was assuming that make.bash would move the binaries to $GOROOT_FINAL. I forgot that it just hardcode the GOROOT into the binaries.

@bcmills
Copy link
Contributor

bcmills commented Jan 22, 2020

The GOBIN variable seems like a red herring: as far as I am aware, it does not affect the install directory for binaries built from GOROOT (including cmd/go).

~$ GOBIN=/tmp go1.12.14 list -f '{{.Target}}' cmd/go
/usr/local/google/home/bcmills/sdk/go1.12.14/bin/go

~$ GOBIN=/tmp go1.14beta1 list -f '{{.Target}}' cmd/go
/usr/local/google/home/bcmills/sdk/go1.14beta1/bin/go

~$ GOBIN=/tmp go list -f '{{.Target}}' cmd/go
/usr/local/google/home/bcmills/go/bin/go

The real problem here, I think, is that clean.bash should not care about GOBIN at all, and today it does.

CC @matloob @jayconrod

@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 22, 2020
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jan 22, 2020
@perillo
Copy link
Contributor Author

perillo commented Jan 22, 2020

A git log --grep=GOBIN -p make.bash reported some interesting informations.

As an example, from https://codereview.appspot.com/2043041, and in detail, from
https://codereview.appspot.com/2043041/patch/8001/9009
it seems that the early build system used some tool that where copied to GOBIN (maybe from an early phase in the build?).

@nikson
Copy link
Contributor

nikson commented Jan 27, 2020

Bash scripts either unset GOBIN or use GOROOT/bin when required. We're now using the GOROOT/bin path explicitly in the clean.bash, thus avoiding GOBIN.

go/src$ grep GOBIN *.bash
iostest.bash:unset GOBIN
make.bash:unset GOBIN # Issue 14340
run.bash:export GOBIN=$GOROOT/bin  # Issue 14340

I've sent another revision with the updated commit message.

@tildeleb
Copy link

tildeleb commented Feb 26, 2020

As a 10 year Go user I was just bitten by NOT having GOBIN work as expected. Let me ask a related question.

Is it a goal (still a goal) that a single GOROOT support multiple GOOS and GOARCH combinations?

I always assumed it does because tools go in ${GOROOT}/pkg/tools/${GOOS}_${GOARCH} and you used to be able to control where the commands were installed with GOBIN. So putting the commands in ${GOROOT}/bin/${GOOS}_${GOARCH} would be consistent with how the tools are installed. I don't understand why the tools are installed a different way than the commands.

Let me explain the environment I am trying to set up. I want to have a single set of directory pairs that define my go environment. One directory for ${GOROOT} and one for ${GOPATH}.

In one case I use these directories locally on my Mac to compile and deploy on Mac ("darwin_amd64"). In another case I mount these directories in a Docker linux container and deploy on Linux ("linux_amd64)". Everything is in sync. Same version of go, same tools, same source code and packages. Everything is self contained. That last statement is worth something right?

By not supporting GOBIN, which was supported for a long time, the decision has effectively been made to eliminate support for multiple multiple GOOS and GOARCH combinations in a single GOROOT and something has been lost.

My proposal is as follows:
Remove support for GOBIN. It is already not supported (unset in make.bash) but that isn't documented, correct? Install commands in ${GOROOT}/bin/${GOOS}_${GOARCH}. That allows support for multiple GOOS and GOARCH in a single GOROOT and it is consistent with the way the tools are installed.

@golang golang locked and limited conversation to collaborators Feb 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants