juanfont/headscale · error
go mod vendor: %w
Error message
go mod vendor: %w
What it means
exec of `go mod vendor -o <tmpdir>` failed in the vendorhash tool, which vendors dependencies to hash them (nardump.SRI) for flake reproducibility checks. cmd.Run() returns a non-zero exit when `go` is not found (exec error), the module graph is broken, or module downloads fail. Stderr is wired through to os.Stderr, so the actual go error message is visible in the command output above this wrapper.
Source
Thrown at cmd/vendorhash/main.go:188
if err != nil {
return "", err
}
// `go mod vendor -o` requires the destination to not already exist.
err = os.Remove(out)
if err != nil {
return "", err
}
defer os.RemoveAll(out)
cmd := exec.CommandContext(ctx, "go", "mod", "vendor", "-o", out)
cmd.Env = append(os.Environ(), "GOWORK=off")
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
return "", fmt.Errorf("go mod vendor: %w", err)
}
return nardump.SRI(os.DirFS(out))
}
func loadHashes() (FlakeHashes, error) {
var h FlakeHashes
b, err := os.ReadFile(hashesFile)
if err != nil {
return h, err
}
err = json.Unmarshal(b, &h)
if err != nil {
return h, fmt.Errorf("%s: %w", hashesFile, err)
}
View on GitHub (pinned to 565fd254d0)
Solutions
- Run `go mod vendor` manually in the repo to see the real error (the tool already pipes stderr)
- Ensure Go is installed/on PATH (inside headscale: `nix develop` gives Go 1.26.1)
- Fix module issues: `go mod tidy`, verify GOPROXY/GOPRIVATE for private modules, check network to proxy.golang.org
- Re-run the vendorhash command once `go mod vendor` succeeds
Example fix
# before: tool fails, stderr shows 'missing go.sum entry' go run ./cmd/vendorhash # after go mod tidy && go mod vendor go run ./cmd/vendorhash
Defensive patterns
Strategy: validation
Validate before calling
if _, err := exec.LookPath("go"); err != nil {
return fmt.Errorf("go toolchain required: %w", err)
}
// dry-run the same operation first; its stderr explains any module problem
if d, err := exec.Command("go", "mod", "vendor", "-o", os.TempDir()+"/vh-probe").CombinedOutput(); err != nil {
return fmt.Errorf("go mod vendor probe failed: %s", d)
} Try / catch
if err := cmd.Run(); err != nil {
var ee *exec.ExitError
if errors.As(err, &ee) {
// go ran and failed — module/network problem; its stderr was already streamed
return "", fmt.Errorf("go mod vendor (exit %d): %w", ee.ExitCode(), err)
}
// go binary itself missing/unusable
return "", fmt.Errorf("go mod vendor: %w", err)
} Prevention
- Run the tool inside `nix develop` so the pinned Go toolchain is on PATH
- Keep go.mod/go.sum consistent (`go mod tidy`) before hashing
- Configure GOPROXY/GOPRIVATE correctly for private modules in CI
When it happens
Trigger: Running cmd/vendorhash when `go` is not on PATH; go.mod/go.sum inconsistent (missing go.sum entries, `go mod tidy` needed); module fetch failures via GOPROXY (private modules, proxy down, GONOSUMDB/GOPRIVATE misconfigured); GOWORK=off interacting badly with a workspace setup.
Common situations: Running the tool outside `nix develop` where the pinned Go 1.26.1 toolchain is absent; CI without module-cache credentials for private deps; a go.sum updated by hand; GOPROXY=direct with network restrictions.
Related errors
AI-assisted analysis of juanfont/headscale@565fd254d0 (2026-08-15).
Data as JSON: /api/errors/25086df2cfd3a3a0.
Report an issue: GitHub.