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

Using golang.org/dl/go1.12 with testscript #63

Open
pwaller opened this issue Mar 16, 2019 · 3 comments
Open

Using golang.org/dl/go1.12 with testscript #63

pwaller opened this issue Mar 16, 2019 · 3 comments

Comments

@pwaller
Copy link

pwaller commented Mar 16, 2019

Hi, I have go in my $PATH by symlinking to a golang.org/dl/go* binary. The problem is, that binary seems to locate itself by using the home directory.

The net result is that when I run this, exec go build doesn't work, because:

> exec go build
[stderr]
go1.12: not downloaded. Run 'go1.12 download' to install to /no-home/sdk/go1.12

... i.e, it thinks it isn't yet installed. Any tricks for working around this?

@myitcv
Copy link
Collaborator

myitcv commented Mar 21, 2019

@mvdan - do you use golang.org/dl/go*?

I'm afraid I don't use it. Instead I have full installs and use process mount namespaces to flip between versions (largely to avoid any issues with binaries being called go1.12 etc)

@mvdan
Copy link
Collaborator

mvdan commented Mar 21, 2019

Hmm, I do use golang.org/dl/go* for old Go versions. Right now, I have go1.11.5 set up via that.

Perhaps a way to work around this would be to run testscript with an explicit GOROOT, and then teach programs like go1.11.5 to look there.

@mvdan
Copy link
Collaborator

mvdan commented Apr 15, 2024

With https://go.dev/doc/toolchain existing today, I think this problem is "solved" as long as GOTOOLCHAIN is forwarded into testscripts. We already have a bit of code that does this for other env vars, so we could add it there as well:

// These env vars affect how a Go program behaves at run-time;
// If the user or `go test` wrapper set them, we should propagate them
// so that sub-process commands run via the test binary see them as well.
for _, name := range []string{
// If we are collecting coverage profiles, e.g. `go test -coverprofile`.
"GOCOVERDIR",
// If the user set GORACE when running a command like `go test -race`,
// such as GORACE=atexit_sleep_ms=10 to avoid the default 1s sleeps.
"GORACE",
} {
if val := os.Getenv(name); val != "" {
env.Vars = append(env.Vars, name+"="+val)
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants