golang/go · error
open %s: %v
Error message
open %s: %v
What it means
When `objfile.Open` is called, it first tries to parse the file as a Go object file or archive. If that fails with `archive.ErrGoObjOtherVersion`, this error is returned. That specific error type indicates the archive was produced by a different Go toolchain version whose object format is incompatible with the current one.
Source
Thrown at src/cmd/internal/objfile/objfile.go:79
var openers = []func(io.ReaderAt) (rawFile, error){
openElf,
openMacho,
openPE,
openPlan9,
openXcoff,
}
// Open opens the named file.
// The caller must call f.Close when the file is no longer needed.
func Open(name string) (*File, error) {
r, err := os.Open(name)
if err != nil {
return nil, err
}
if f, err := openGoFile(r); err == nil {
return f, nil
} else if _, ok := err.(archive.ErrGoObjOtherVersion); ok {
return nil, fmt.Errorf("open %s: %v", name, err)
}
for _, try := range openers {
if raw, err := try(r); err == nil {
return &File{r, []*Entry{{raw: raw}}}, nil
}
}
r.Close()
return nil, fmt.Errorf("open %s: unrecognized object file", name)
}
func (f *File) Close() error {
return f.r.Close()
}
func (f *File) Entries() []*Entry {
return f.entries
}
View on GitHub (pinned to b6b368adc5)
Solutions
- Clean the build cache and rebuild from source: `go clean -cache && go build`.
- Ensure all object files were compiled with the same Go toolchain version: `go version` on all build machines.
- Remove stale `.a` files in vendor or local directories.
- Pin the Go version consistently across all environments (CI, local, deploy).
Example fix
// before — stale archives from old Go version $ go build ./... // fails if .a files are from older Go // after — clean cache and rebuild $ go clean -cache $ go build ./...
Defensive patterns
Strategy: validation
Validate before calling
// Check Go version consistency before opening archives
func checkGoObjVersion(path string) error {
f, err := objfile.Open(path)
if err != nil {
if strings.Contains(err.Error(), "ErrGoObjOtherVersion") {
return fmt.Errorf("stale archive from different Go version — run 'go clean -cache' and rebuild")
}
return err
}
f.Close()
return nil
} Try / catch
f, err := objfile.Open(path)
if err != nil && strings.Contains(err.Error(), path) {
// Could be version mismatch — suggest cache clean
log.Printf("Failed to open %s. Try 'go clean -cache' if Go was recently upgraded.", path)
} Prevention
- Run 'go clean -cache' after upgrading Go versions.
- Pin Go version consistently across CI, local, and deploy environments.
- Remove stale .a files in vendor and build directories after version changes.
When it happens
Trigger: Calling `objfile.Open` on a Go archive or object file that was compiled with a different major/minor Go version. The Go object file format (`goobj`) is versioned and changes between Go releases, so object files from one version generally cannot be consumed by another.
Common situations: Stale build caches or archives left over from a Go version upgrade. Mixing object files compiled with different Go versions (e.g., Go 1.21 and Go 1.22). Linking object files produced by a different Go installation. Using a CI pipeline that caches `.a` files across Go version upgrades.
Related errors
- open %s: unrecognized archive member %s
- corrupt archive
- truncated archive
- pcln not available in go object file
- unknown load address
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/1c72d04c89798587.
Report an issue: GitHub.