Skip to content

fix: skip setup_golang.sh on hosts without apt-get#8462

Merged
aadhar-agarwal merged 1 commit into
mainfrom
aadagarwal/setup-golang-skip-non-apt
May 6, 2026
Merged

fix: skip setup_golang.sh on hosts without apt-get#8462
aadhar-agarwal merged 1 commit into
mainfrom
aadagarwal/setup-golang-skip-non-apt

Conversation

@aadhar-agarwal

@aadhar-agarwal aadhar-agarwal commented May 6, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

What

Make hack/setup_golang.sh a no-op when apt-get is unavailable, instead of failing with apt-get: command not found. If Go is missing on PATH, fail with a clear error message.

Why

The setup-golang make 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 via tdnf).

Behavior

Host Before After
Ubuntu (apt-get) Installs/updates msft-golang Unchanged
Non-Ubuntu (no apt-get) Fails: apt-get: command not found Logs notice + go version, exits 0
Non-Ubuntu, Go missing Fails: apt-get: command not found Fails with explicit error: 'go' is not on PATH

Which issue(s) this PR fixes:

Fixes #

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>
Copilot AI review requested due to automatic review settings May 6, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.sh when apt-get is unavailable.
  • On non-apt-get hosts, verify go is on PATH, print go version, and exit successfully; otherwise fail with a clear error.

Comment thread hack/setup_golang.sh
@aadhar-agarwal aadhar-agarwal merged commit 27face4 into main May 6, 2026
26 checks passed
@aadhar-agarwal aadhar-agarwal deleted the aadagarwal/setup-golang-skip-non-apt branch May 6, 2026 22:33
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

Successfully merging this pull request may close these issues.

3 participants