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

build: unset GOWORK when building #51558

Closed
hyangah opened this issue Mar 9, 2022 · 3 comments
Closed

build: unset GOWORK when building #51558

hyangah opened this issue Mar 9, 2022 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Mar 9, 2022

I forgot I had the GOWORK env var left set in my terminal,
when I ran gotip download. The env var silently affects how the go is built.

Luckily I had an invalid value for GOWORK this time and build failed so I could catch this.
Otherwise, gotip download would silently succeed - I am not sure whether it is built correctly or not.
(It's likely that GOWORK didn't affect the built, but who knows)

It's a user error, but with go env -w or use of various env vars, it's a mistake easy to make.
Please consider gotip download ensures to unset GOWORK or other env vars (GOFLAGS?)
that may interfere with the clean build, or at least, report possible erroneous env vars during build.

$ gotip env GOWORK
some/relative/path/go.work
$ gotip download
Updating the go development tree...
From https://go.googlesource.com/go
* branch                  master     -> FETCH_HEAD
HEAD is now at c6d9b38dd8 cmd/internal/obj/arm64: optimize function prologue/epilogue with STP/LDP
Building Go cmd/dist using /Users/hakim/sdk/go1.17. (go1.17 darwin/amd64)
Building Go toolchain1 using /Users/hakim/sdk/go1.17.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
the path provided to GOWORK must be an absolute path
go tool dist: FAILED: /Users/hakim/sdk/gotip/pkg/tool/darwin_amd64/go_bootstrap install -gcflags=all= -ldflags=all= -i cmd/asm cmd/cgo cmd/compile cmd/link: exit status 1
gotip: failed to build go: exit status 
@dr2chase dr2chase added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Mar 9, 2022
@dr2chase
Copy link
Contributor

dr2chase commented Mar 9, 2022

@dmitshur

@dmitshur dmitshur changed the title golang.org/dl/gotip: unset GOWORK when building dl/gotip: unset GOWORK when building Mar 9, 2022
@dmitshur
Copy link
Contributor

Thanks for reporting.

gotip download uses the current environment, only overriding GOROOT_BOOTSTRAP, and simply delegates to make.{bash,bat,rc} for building from source. (It probably can't use a clean environment because PATH is needed to find a C compiler, etc.)

This problem can also be reproduced with just make.bash:

$ export GOWORK=some/relative/path/go.work
$ git clone https://go.googlesource.com/go gotip
Cloning into 'gotip'...
[...]
$ cd gotip/src
src $ ./make.bash
the path provided to GOWORK must be an absolute path

It also reproduces if GOWORK isn't set, but there's a go.work file in a parent directory:

$ mkdir parentdirwithgoworkfile && cd parentdirwithgoworkfile 
$ echo "go 1.18" > go.work
$ git clone https://go.googlesource.com/go gotip 
[...]
$ ls
go.work	gotip
$ cd gotip/src
src $ ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.18 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
go: warning: "bootstrap/cmd/..." matched no packages
go tool dist: open /Users/gopher/parentdirwithgoworkfile/gotip/pkg/bootstrap/bin/asm: no such file or directory

It's probably better to fix this in the build script, since that way it will help both when installing from source and when using gotip, so retitling.

CC @matloob, @bcmills.

@dmitshur dmitshur changed the title dl/gotip: unset GOWORK when building build: unset GOWORK when building Mar 18, 2022
@dmitshur dmitshur added this to the Backlog milestone Mar 18, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/393879 mentions this issue: build: force GOWORK=off in make.{bash,bat,rc}

@dmitshur dmitshur modified the milestones: Backlog, Go1.19 Mar 21, 2022
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Mar 21, 2022
@golang golang locked and limited conversation to collaborators Mar 21, 2023
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

4 participants