Skip to content

add checking GOROOT environment variable #2346

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

Closed
wants to merge 1 commit into from

Conversation

t-matsuo
Copy link

If there is no GOROOT environment variable, 'operator-sdk add api'
fails.
see #1854 (comment)

Description of the change:

Motivation for the change:

If there is no GOROOT environment variable, 'operator-sdk add api'
fails.
see operator-framework#1854 (comment)
@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 19, 2019
@joelanford
Copy link
Member

Technically, GOROOT only has to be explicitly set if the user's GOROOT is different than the GOROOT used to build the binary.

However, given that different maintainers create the release artifacts and that they have different environments themselves, there's no guarantee that the build GOROOT would be consistent release to release. There's also no way to determine what the build GOROOT was at runtime. So it seems to me that setting GOROOT is something most users who are not building from source are probably having to do.

There may be a way to solve this in the SDK binary itself, so that users do not need to worry about this at all. Something like the following is what I've been thinking of adding in the code generation code where this problem arises:

out, err := exec.Command("go", "env", "GOROOT").CombinedOutput()
if err != nil {
    // handle err
}
if err := os.SetEnv("GOROOT", string(out)); err != nil {
    // handle err
}

@t-matsuo
Copy link
Author

I think solving it in the SDK binary itself is better than checking GORROOT too, so I will close this PR.
Thanks.

@t-matsuo t-matsuo closed this Dec 19, 2019
@joelanford
Copy link
Member

@t-matsuo Would you be interested in working on a PR to solve it in the SDK binary?

@t-matsuo
Copy link
Author

@joelanford I'm interested in it, but I am beginner at operator-sdk. I want someone to create a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants