golang/go · error

open %s: unrecognized archive member %s

Error message

open %s: unrecognized archive member %s

What it means

When opening a Go archive (`.a` file), the loader iterates through archive members. For `EntryNativeObj` members, it tries each registered opener (ELF, Mach-O, PE, Plan9, XCOFF). If none can parse the member, this error is returned. It means the archive contains a native object file in a format that no registered opener recognizes.

Source

Thrown at src/cmd/internal/objfile/goobj.go:72

			}
			entries = append(entries, &Entry{
				name: e.Name,
				raw:  &goobjFile{e.Obj, r, f, arch},
			})
			continue
		case archive.EntryNativeObj:
			nr := io.NewSectionReader(f, e.Offset, e.Size)
			for _, try := range openers {
				if raw, err := try(nr); err == nil {
					entries = append(entries, &Entry{
						name: e.Name,
						raw:  raw,
					})
					continue L
				}
			}
		}
		return nil, fmt.Errorf("open %s: unrecognized archive member %s", f.Name(), e.Name)
	}
	return &File{f, entries}, nil
}

func goobjName(name string, ver int) string {
	if ver == 0 {
		return name
	}
	return fmt.Sprintf("%s<%d>", name, ver)
}

type goobjReloc struct {
	Off  int32
	Size uint8
	Type objabi.RelocType
	Add  int64
	Sym  string
}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Rebuild the archive from source with the current Go toolchain to ensure format compatibility.
  2. Verify archive integrity: `go tool nm <archive>` or `ar t <archive>`.
  3. Ensure all member objects target the same GOOS/GOARCH.
  4. Check for truncation or corruption: rebuild if the archive was incompletely written.

Example fix

// before — stale archive from old toolchain
f, err := objfile.Open("old.a")  // fails: unrecognized member

// after — rebuild archive with current toolchain
$ go build -o lib.a ./...
f, err := objfile.Open("lib.a")  // succeeds
Defensive patterns

Strategy: try-catch

Try / catch

f, err := objfile.Open(archivePath)
if err != nil {
    if strings.Contains(err.Error(), "unrecognized archive member") {
        // Rebuild the archive from source
        log.Printf("Archive may be stale or corrupt, rebuilding...")
        return rebuildAndRetry(archivePath)
    }
    return err
}

Prevention

When it happens

Trigger: Calling `objfile.Open` on a Go archive file where one of the member objects is corrupt, truncated, or in an unsupported binary format. Also triggered when the archive was built for an architecture or OS that the current openers do not cover.

Common situations: Mixing archives built with different Go versions or for different platforms. Archive corruption from incomplete builds or filesystem issues. Using a Go toolchain version that does not support the object format used in the archive.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/144e0527f87958b9. Report an issue: GitHub.