dotnet/runtime · error · RuntimeError

Unknown OS.

Error message

Unknown OS.

What it means

Thrown by upload_command() when coreclr_args.host_os is not one of 'osx', 'linux', or 'windows'. The host_os determines the file extension filter used to find cross-compilation JITs in the product directory (.dylib, .so, or .dll respectively). An unrecognized OS means the script cannot determine which JIT file extensions to look for.

Source

Thrown at src/coreclr/scripts/jitrollingbuild.py:414

    # and so on, and live in the same product directory as the primary JIT.
    #
    # Note that the expression below explicitly filters out the primary JIT since we added that above.
    # We handle the primary JIT specially so we can error if it is missing. For the cross-compilation
    # JITs, we don't bother trying to ensure that all the ones we might expect are actually there.
    #
    # We don't do a recursive walk because the JIT is also copied to the "sharedFramework" subdirectory,
    # so we don't want to pick that up.

    if coreclr_args.host_os == "osx":
        allowed_extensions = [ ".dylib" ]
        # Add .dwarf for debug info
    elif coreclr_args.host_os == "linux":
        allowed_extensions = [ ".so" ]
        # Add .dbg for debug info
    elif coreclr_args.host_os == "windows":
        allowed_extensions = [ ".dll" ]
    else:
        raise RuntimeError("Unknown OS.")

    cross_jit_paths = [os.path.join(coreclr_args.product_location, item)
                       for item in os.listdir(coreclr_args.product_location)
                       if re.match(r'.*clrjit.*', item) and item != jit_name and any(item.endswith(extension) for extension in allowed_extensions)]
    files += cross_jit_paths

    # On Windows, grab the PDB files from a sub-directory.
    # if coreclr_args.host_os == "windows":
    #    pdb_dir = os.path.join(coreclr_args.product_location, "PDB")
    #    if os.path.isdir(pdb_dir):
    #        pdb_paths = [os.path.join(pdb_dir, item) for item in os.listdir(pdb_dir) if re.match(r'.*clrjit.*', item)]
    #        files += pdb_paths

    # Figure out which git hash to use for the upload. By default, it is the required coreclr_args.git_hash argument.
    # However, if "--use_latest_jit_change" is passed, we look backwards in the git log for the nearest git commit
    # with a JIT change (it could, and often will be, the same as the argument git_hash).
    jit_git_hash = coreclr_args.git_hash

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Check the -host_os argument value and ensure it is exactly 'windows', 'linux', or 'osx'.
  2. If auto-detecting, verify that the platform detection in coreclr_arguments.py returns one of the three supported values.
  3. Do not pass -host_os and let the script auto-detect from the current platform.

Example fix

# before: misspelled OS
python jitrollingbuild.py upload -git_hash abc123 -host_os mac

# after: correct OS name
python jitrollingbuild.py upload -git_hash abc123 -host_os osx
Defensive patterns

Strategy: validation

Validate before calling

# Validate host_os before calling upload
valid_oses = {'osx', 'linux', 'windows'}
if coreclr_args.host_os not in valid_oses:
    raise ValueError(f'host_os must be one of {valid_oses}, got: {coreclr_args.host_os}')

Type guard

def is_supported_upload_os(host_os: str) -> bool:
    return host_os in {'osx', 'linux', 'windows'}

Try / catch

try:
    upload_command(coreclr_args)
except RuntimeError as e:
    if 'Unknown OS' in str(e):
        logging.error('host_os must be windows, linux, or osx')
        sys.exit(1)
    raise

Prevention

When it happens

Trigger: In upload_command() at lines 405-414: the if/elif chain checks host_os for 'osx', 'linux', 'windows'. If none match, line 414 raises. This occurs when -host_os is set to an unsupported value like 'freebsd', 'android', or an empty/misspelled string.

Common situations: The -host_os argument is misspelled or set to a value the script doesn't support (e.g., 'mac' instead of 'osx', 'win' instead of 'windows'). The OS auto-detection logic in CoreclrArguments picked up an unusual platform string. Running on an OS not yet supported by the rolling build infrastructure.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/cdcd0698429b5aad. Report an issue: GitHub.