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

Missing environment variables in Install method of gobin task #62

Closed
svengreb opened this issue Jan 4, 2021 · 0 comments · Fixed by #63
Closed

Missing environment variables in Install method of gobin task #62

svengreb opened this issue Jan 4, 2021 · 0 comments · Fixed by #63

Comments

@svengreb
Copy link
Owner

svengreb commented Jan 4, 2021

Currently the Install method of the gobin task runner sets the environment of the command that gets executed initially to os.Environ(), but overrides it later on with custom variables configured through the WithEnv(map[string]string) option.

This results in errors when running the method in minimal environments like containers:

build cache is required, but could not be located: GOCACHE is not defined and neither $XDG_CACHE_HOME nor $HOME are defined

This can be fixed by ensuring that the inherited OS environment is prepended before applying custom environment variables.
Also to improve the debugging process the combined output (stdout + stderr) should be included in the error when the command execution fails.

@svengreb svengreb added this to the Next milestone Jan 4, 2021
@svengreb svengreb self-assigned this Jan 4, 2021
svengreb added a commit that referenced this issue Jan 4, 2021
Before the `Install` method of the `gobin` task runner [1] has set the
environment of the command that gets executed initially to
`os.Environ()` [2], but has overwritten it later on with custom
variables configured through the `WithEnv(map[string]string)`
option [3].

This resulted in errors when running the method in minimal environments
like containers:

```raw
build cache is required, but could not be located: GOCACHE is not
defined and neither $XDG_CACHE_HOME nor $HOME are defined
```

This commit fixes it by ensuring that the inherited OS environment is
prepended before applying custom environment variables.
Also to improve the debugging process the combined output
(`stdout` + `stderr`) is now included in the error when the command
execution fails.

[1]: https://pkg.go.dev/github.com/svengreb/[email protected]/pkg/task/gobin#Runner.Install
[2]: https://pkg.go.dev/os/#Environ
[3]: https://pkg.go.dev/github.com/svengreb/[email protected]/pkg/task/gobin#WithEnv

GH-62
svengreb added a commit that referenced this issue Jan 4, 2021
…#63)

Before the `Install` method of the `gobin` task runner [1] has set the
environment of the command that gets executed initially to
`os.Environ()` [2], but has overwritten it later on with custom
variables configured through the `WithEnv(map[string]string)`
option [3].

This resulted in errors when running the method in minimal environments
like containers:

```raw
build cache is required, but could not be located: GOCACHE is not
defined and neither $XDG_CACHE_HOME nor $HOME are defined
```

This commit fixes it by ensuring that the inherited OS environment is
prepended before applying custom environment variables.
Also to improve the debugging process the combined output
(`stdout` + `stderr`) is now included in the error when the command
execution fails.

[1]: https://pkg.go.dev/github.com/svengreb/[email protected]/pkg/task/gobin#Runner.Install
[2]: https://pkg.go.dev/os/#Environ
[3]: https://pkg.go.dev/github.com/svengreb/[email protected]/pkg/task/gobin#WithEnv

Fixes GH-62
@svengreb svengreb removed their assignment Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant