fix: skip setup_golang.sh on hosts without apt-get#8462
Merged
Conversation
setup-golang (added in #8324) unconditionally invokes hack/setup_golang.sh, which runs 'sudo apt-get purge/install msft-golang'. Build pipelines that run on non-Ubuntu hosts (e.g. Azure Linux) fail with 'apt-get: command not found' before reaching the actual build. Make the script a no-op on hosts where apt-get is unavailable, assuming Go is already provided by the build environment, and verify it via 'go version'. Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the repo’s Go bootstrap script used by packer.mk so that hack/setup_golang.sh does not fail on non-Ubuntu build hosts that don’t have apt-get, while still failing clearly when go is missing.
Changes:
- Add an early exit path in
hack/setup_golang.shwhenapt-getis unavailable. - On non-
apt-gethosts, verifygois onPATH, printgo version, and exit successfully; otherwise fail with a clear error.
cameronmeissner
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
What
Make
hack/setup_golang.sha no-op whenapt-getis unavailable, instead of failing withapt-get: command not found. If Go is missing on PATH, fail with a clear error message.Why
The
setup-golangmake target unconditionally calls this script. This causes an issue if running AgentBaker on non-Ubuntu hosts (e.g. the AKS image-build pipeline's Azure Linux 1ES pool, where Go is provided viatdnf).Behavior
msft-golangapt-get: command not foundgo version, exits 0apt-get: command not found'go' is not on PATHWhich issue(s) this PR fixes:
Fixes #