Skip to content

fix(scripts): dead-code ratchet fails confusingly under mixed Go toolchains #1503

Description

@danielgap

📝 Bug Description

scripts/deadcode-ratchet.sh runs go run golang.org/x/tools/cmd/deadcode@v0.30.0 without constraining the Go toolchain. On a machine whose default go is older than the repository's go directive, the analyzer binary is built with the default toolchain and then fails on every package, and the resulting error points at the repository's packages instead of at the analyzer's own build, so it reads like a repository problem rather than a local-toolchain problem.

🔄 Steps to Reproduce

  1. With a default go 1.24.x on PATH and this repository's go directive requiring 1.25, run bash scripts/deadcode-ratchet.sh from the repository root.
  2. Observe the errors below (analyzer exit 1).

✅ Expected Behavior

The ratchet either builds the analyzer with a toolchain that satisfies the go directive (for example deriving GOTOOLCHAIN from it) or fails with a message that names the toolchain mismatch and the remedy.

❌ Actual Behavior

<repo>/internal/version/check.go:2:1: package requires newer Go version go1.25 (application built with go1.24)
<repo>/cmd/engram/autosync_status.go:1:1: package requires newer Go version go1.25 (application built with go1.24)
deadcode: packages contain errors
exit status 1
deadcode analyzer failed; refusing a vacuous comparison

🖥️ Environment

  • Operating System: Linux (Other)
  • Engram Version: n/a — repository scripts on main
  • Agent / Client: Other

💡 Additional Context

Workaround that unblocked a contributor run: build the analyzer explicitly with the required toolchain (GOTOOLCHAIN=go1.25.x go install golang.org/x/tools/cmd/deadcode@v0.30.0) and point the script at it via the existing DEADCODE_RATCHET_ANALYZER override. Plain GOTOOLCHAIN=auto does not help, because the analyzer's own module does not require 1.25, so the default toolchain still builds it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions