golang/go · info

unable to determine OS version: %w

Error message

unable to determine OS version: %w

What it means

On the wasip1 target there is no portable host API to query the OS version, so osinfo.Version() returns errors.ErrUnsupported wrapped in this message. It is a deliberate 'not implemented' rather than a transient failure.

Source

Thrown at src/cmd/internal/osinfo/os_wasip1.go:16

// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build wasip1

package osinfo

import (
	"errors"
	"fmt"
)

// Version returns the OS version name/number.
func Version() (string, error) {
	return "", fmt.Errorf("unable to determine OS version: %w", errors.ErrUnsupported)
}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Handle errors.ErrUnsupported gracefully in the caller.
  2. Do not depend on a host OS version when targeting wasip1.
Defensive patterns

Strategy: fallback

Type guard

// Detect wasip1 and skip version-dependent behavior.
// if v, err := osinfo.Version(); err != nil {
//     if errors.Is(err, errors.ErrUnsupported) {
//         // wasip1: host version unavailable; use a static label
//     }
// }

Try / catch

// v, err := osinfo.Version()
// if err != nil {
//     if errors.Is(err, errors.ErrUnsupported) {
//         v = "unknown (wasip1)"
//     } else {
//         return err
//     }
// }

Prevention

When it happens

Trigger: Calling osinfo.Version() in any wasip1 build.

Common situations: Standard behavior for Go programs compiled for wasip1 that call into osinfo (directly or transitively). Not a defect.

Related errors


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