Skip to content

make complexity breaks when GOBIN is set, Go programs install only to ~/.local/bin, and every lint tool gets pinned #1006

Open

Description

@David-Noble-at-work

make complexity cannot survive GOBIN being set, and the ruling of 2026-10-01 requires it to be set:
Go programs install to ~/.local/bin and nowhere else.

The target installs gocyclo and then looks for it at a path it computed itself:

complexity: ## Check cyclomatic complexity (max 20)
	echo "Checking cyclomatic complexity (max 20)..."
	$(HOST_GO) install github.com/fzipp/gocyclo/cmd/gocyclo@latest
	gocyclo_bin="$$(go env GOPATH)/bin/gocyclo"
	[ -x "$$gocyclo_bin" ] || { echo "ERROR: gocyclo not found at $$gocyclo_bin after 'go install'"; exit 1; }

go install honors GOBIN over GOPATH/bin. So with GOBIN=~/.local/bin the install succeeds, line 511
looks in ~/go/bin, line 512 finds nothing, and the target fails with its own error message naming a path
nothing ever wrote to. The target is correct only while GOBIN is unset, which is a dependency on a machine's
environment that a build target has no business having.

Measured on this machine, 2026-10-01

GOBIN was unset and ~/go/bin held gocyclo.exe -- and ~/go/bin was not on PATH, so the binary the
target installs had never been callable by name. C:\Program Files\Go\bin is on PATH and matches a careless
*go\bin* glob, which is how that goes unnoticed.

Three sites install a Go program outside ~/.local/bin

Site What it does Breaks when GOBIN moves?
Makefile:511 looks for gocyclo at $(go env GOPATH)/bin Yes. make complexity fails immediately
Makefile:493 advises installing golangci-lint to $(go env GOPATH)/bin No, but it directs an install off PATH and outside the policy
.github/workflows/ci.yaml:98 CI installs golangci-lint to $(go env GOPATH)/bin No. The runner carries GOPATH/bin on PATH

make install is already compliant: it passes PREFIX=~/.local to each program's self install.

The fix is to stop installing it at all

Go 1.24 introduced tool directives in go.mod; this module declares go 1.27.0. A tool directive pins the
version in go.sum and go tool builds it into GOCACHE and runs it. Nothing is installed, so there is no
location to assume -- not GOBIN, not GOPATH, not PATH.

complexity: ## Check cyclomatic complexity (max 20)
	echo "Checking cyclomatic complexity (max 20)..."
	violations="$$($(HOST_GO) tool gocyclo -over 20 . | grep -v '_test.go' || true)"

Four lines become one: the go install, the path computation, and the -x existence check all go away.

Verified before proposing it, in a throwaway module

$ go get -tool github.com/fzipp/gocyclo/cmd/gocyclo
go: downloading github.com/fzipp/gocyclo v0.6.0
go: added github.com/fzipp/gocyclo v0.6.0

$ cat go.mod
tool github.com/fzipp/gocyclo/cmd/gocyclo
require github.com/fzipp/gocyclo v0.6.0 // indirect

$ go tool gocyclo -over 20 .
GO_TOOL_EXIT=0

$ ls ~/.local/bin | grep gocyclo
nothing installed -- correct

What this gives up, stated plainly

gocyclo enters the module graph as a tool dependency with an // indirect require. go.mod and go.sum
must be committed together or CI's go mod tidy verification goes red. In exchange the version stops being
@latest -- today every run of make complexity can silently pick up a new gocyclo with new findings, which
is its own reproducibility defect.

Makefile:493 is a one-word change: the advisory message names ~/.local/bin instead of
$(go env GOPATH)/bin. The verification at line 485 already resolves golangci-lint from PATH, so it is
correctly location-independent; only the advice is wrong.

Every lint tool gets pinned, in this change

Ruled 2026-10-01: "pin it." shellcheck and shfmt are pinned nowhere -- CI takes whatever apt-get
ships (ci.yaml:109) -- while PSScriptAnalyzer is pinned to an exact version (ci.yaml:170). Same
repository, same class of tool, two standards.

Tool Pinned today? Becomes
golangci-lint Yes, GOLANGCI_LINT_VERSION + a version-check target unchanged
PSScriptAnalyzer Yes, 1.25.0, exact unchanged
gocyclo No -- @latest on every run pinned by the go.mod tool directive
shellcheck No -- apt-get install -y shellcheck 0.11.0, pinned, installed by exact release
shfmt No v3.14.1, pinned

0.11.0 is the version installed on the owner's machine 2026-10-01, and the pin matters more than the number:
its changelog adds six checks (SC2327, SC2328, SC2329, SC2330, SC2331, SC2332, SC3062) and disables SC2002
by default
. So an unpinned gate diverges from CI in both directions -- a file that passes locally can fail in
CI, and a file that fails locally can pass. A gate whose findings move without a commit cannot be trusted,
which is the whole point of the pin.

shfmt is a Go program, so under the policy it installs to ~/.local/bin like any other -- measured there at
v3.14.1 on 2026-10-01. shellcheck is Haskell and has no native Windows ARM64 build; winget places it in
WinGet/Links, which is on PATH and already serves golangci-lint, so it needs no redirection.

Measured while scoping this, and recorded so it is not re-derived

With all four tools installed, both shell gates pass -- and they do not see the same files:

Gate Discovery Files Result
star lint shell . (CI, ci.yaml:122) extension: .sh, .bash, .zsh 12 pass
shell-lint.sh (pre-commit, make check) shebang 45 pass, exit 0

The 33-file gap is star lint shell's: it cannot see .githooks/pre-commit, install.sh is found only by its
extension, and no extensionless script is discovered at all. Nothing is hiding behind the gap -- both pass --
but the weaker instrument is the one CI runs. That belongs with lint coverage, not here.

Out of scope

.github/workflows/ci.yaml:98 keeps installing golangci-lint to $(go env GOPATH)/bin. The runner has that
directory on PATH, the install works, and changing a green gate for consistency alone trades risk for
tidiness.

Activity

  1. changed the title [-]make complexity breaks when GOBIN is set, and three sites install Go programs outside ~/.local/bin[/-] [+]make complexity breaks when GOBIN is set, Go programs install only to ~/.local/bin, and every lint tool gets pinned[/+] on Oct 1, 2026
  2. David-Noble-at-work commented on Nov 9, 2026

    @David-Noble-at-work
    ContributorAuthor

    star github triage sweep added this issue to Triage: devlore, for the rules it breaks:

    • severity: a Bug whose Severity is blank; a bug is Critical, High, Medium or Low
    • no-evidence: no Evidence of completion section
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions