Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Autobuilder: fall back when os.Executable fails #383

Merged

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Oct 22, 2020

This can happen under tracing, perhaps because of https://github.com/github/codeql-tracer/issues/29

This can happen under tracing, perhaps because of github/codeql-tracer#29
@smowton smowton requested a review from a team October 22, 2020 12:22
case "windows":
return "win64", nil
}
return "", errors.New("Unknown OS: " + runtime.GOOS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I like the fmt.Errorf more than errors.New, but that's entirely a style thing. Also, I think "unsupported" is more accurate here.

Suggested change
return "", errors.New("Unknown OS: " + runtime.GOOS)
return "", fmt.Errorf("Unsupported OS: %s", runtime.GOOS)

// Fall back to rebuilding our own path from the extractor root:
extractorRoot := os.Getenv("CODEQL_EXTRACTOR_GO_ROOT")
if extractorRoot == "" {
return "", errors.New("CODEQL_EXTRACTOR_GO_ROOT not set")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have a similar message here as when CODEQL_EXTRACTOR_GO_SOURCE_ARCHIVE_DIR is unset below.

@smowton
Copy link
Contributor Author

smowton commented Oct 22, 2020

I'll improve the message in a followup since time it pressing

@smowton smowton merged commit 6122223 into github:main Oct 22, 2020
@@ -206,6 +207,51 @@ func checkVendor() bool {
return true
}

func getOsToolsSubdir() (string, error) {
Copy link
Contributor

@aibaars aibaars Oct 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is known asos.Getenv("CODEQL_PLATFORM")

Copy link
Contributor Author

@smowton smowton Oct 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but that was being filtered out, presumably also by the tracer. It was known to autobuild.sh but not its child go-autobuild.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matt-gretton-dann The tracer shouldn't filter out CODEQL_ variables, right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tracer has a concept of critical variables which it tries to preserve in the environment. But also when the tracer is turned off (as is the case when we trace go-autouild) we remove those critical variables. I believe this was historically deemed appropriate to try and preserve the environment the user would expect

CODEQL_PLATFORM is one of those critical env. vars.

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

Successfully merging this pull request may close these issues.

4 participants