Skip to content

fix: set GOTOOLCHAIN=local in snapcraft.yaml to prevent auto-download - #2012

Merged
TerryHowe merged 2 commits into
oras-project:mainfrom
TerryHowe:fix/snap-gotoolchain-local
Mar 20, 2026
Merged

TerryHowe merged 2 commits into
oras-project:mainfrom
TerryHowe:fix/snap-gotoolchain-local

Conversation

@TerryHowe

Copy link
Copy Markdown
Member

Problem

When building the snap package, if the Go toolchain installed via the build snap is older than the version specified in go.mod, Go's default GOTOOLCHAIN=auto behavior causes it to attempt downloading a newer toolchain. Snapcraft's environment validator then receives the download progress message (e.g. go: downloading go1.x.x (linux/amd64)) as the Go compiler version string — which is invalid — causing the snap build to fail.

This was observed in the release-1.3 snap CI job: https://github.com/oras-project/oras/actions/runs/23341326576/job/67895417718

Fix

Add GOTOOLCHAIN: "local" to the build-environment in snapcraft.yaml. This ensures the snap's bundled Go toolchain is always used, preventing unexpected downloads during snap builds. The go/1.25/stable snap channel tracks the latest Go 1.25 patch releases and is compatible with the go 1.25.7 requirement in go.mod.

When Go's GOTOOLCHAIN is set to 'auto' (the default), it will attempt
to download a newer Go toolchain if go.mod specifies a version higher
than the currently installed one. During a snap build, snapcraft's
environment validator receives the download progress string (e.g.
'go: downloading go1.x.x (linux/amd64)') as the Go compiler version,
which is not a valid version string, causing the build to fail.

Setting GOTOOLCHAIN=local ensures the snap's bundled Go toolchain is
always used, preventing unexpected downloads during snap builds.

Signed-off-by: Terry Howe <[email protected]>
@codecov

codecov Bot commented Mar 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.18%. Comparing base (338759d) to head (fa830b7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2012   +/-   ##
=======================================
  Coverage   87.18%   87.18%           
=======================================
  Files         143      143           
  Lines        5539     5539           
=======================================
  Hits         4829     4829           
  Misses        423      423           
  Partials      287      287           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe
TerryHowe merged commit 5823024 into oras-project:main Mar 20, 2026
7 checks passed
@TerryHowe
TerryHowe deleted the fix/snap-gotoolchain-local branch March 20, 2026 22:01
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.

2 participants