{"record":{"id":"b989f8f3fd89ad82","repo":"golangci/golangci-lint","slug":"failed-to-calculate-binary-salt-w","errorCode":null,"errorMessage":"failed to calculate binary salt: %w","messagePattern":"failed to calculate binary salt: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/run.go","lineNumber":628,"sourceCode":"func formatMemory(memBytes uint64) string {\n\tconst Kb = 1024\n\tconst Mb = Kb * 1024\n\n\tif memBytes < Kb {\n\t\treturn fmt.Sprintf(\"%db\", memBytes)\n\t}\n\tif memBytes < Mb {\n\t\treturn fmt.Sprintf(\"%dkb\", memBytes/Kb)\n\t}\n\treturn fmt.Sprintf(\"%dmb\", memBytes/Mb)\n}\n\n// Related to cache.\n\nfunc initHashSalt(logger logutils.Log, version string, cfg *config.Config) error {\n\tbinSalt, err := computeBinarySalt(version)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to calculate binary salt: %w\", err)\n\t}\n\n\tconfigSalt, err := computeConfigSalt(cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to calculate config salt: %w\", err)\n\t}\n\n\tgoModSalt, err := computeGoModSalt()\n\tif err != nil {\n\t\t// NOTE: missing go.mod must be ignored.\n\t\tlogger.Warnf(\"Failed to calculate go.mod salt: %v\", err)\n\t}\n\n\tb := bytes.NewBuffer(binSalt)\n\tb.WriteString(\"golangci-lint-cache/v2\")\n\tb.Write(configSalt)\n\tb.WriteString(goModSalt)\n","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/run.go#L610-L646","documentation":"initHashSalt computes a binary salt (used for cache invalidation keys) via computeBinarySalt, which locates the running executable and hashes its content/version. Any failure resolving or hashing the binary is wrapped as \"failed to calculate binary salt\".","triggerScenarios":"os.Executable() fails or the executable file cannot be read/hashed — e.g. the binary was deleted/replaced mid-run, running via a broken symlink, or an exotic exec environment where the executable path is unavailable.","commonSituations":"Container images where the binary is removed after entrypoint exec; go run temp binaries being garbage-collected concurrently; unusual sandboxes hiding /proc/self/exe.","solutions":["Re-run the command; transient mid-run binary replacement is the usual cause.","Install/keep the golangci-lint binary on stable storage instead of a temp path (avoid `go run` for repeated cache-dependent runs).","If using a wrapper/symlink, ensure the symlink target exists.","Clear the golangci-lint cache (`golangci-lint cache clean`) after upgrading the binary."],"exampleFix":"// before\ngo run github.com/golangci/golangci-lint/cmd/golangci-lint run   # temp binary path issues\n// after\ngo install github.com/golangci/golangci-lint/cmd/golangci-lint@latest\ngolangci-lint run","handlingStrategy":"try-catch","validationCode":"exe, err := os.Executable()\nif err != nil {\n\treturn fmt.Errorf(\"executable path unavailable; binary salt computation will fail\")\n}\nif _, err := os.Stat(exe); err != nil {\n\treturn fmt.Errorf(\"golangci-lint binary missing at %s\", exe)\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil && strings.Contains(err.Error(), \"failed to calculate binary salt\") {\n\tlog.Printf(\"binary salt failed (binary replaced/deleted mid-run?); rerun: %v\", err)\n}","preventionTips":["Run a stable installed golangci-lint binary, not `go run` temp binaries.","Avoid deleting/replacing the binary while it executes (common in self-updating scripts).","Resolve wrapper symlinks to real files before exec."],"tags":["cache","hashing","binary","golangci-lint"],"backgroundTag":"binary-salt-computation-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}