dotnet/runtime · error · RuntimeError

Cannot find System.Private.CoreLib.dll at {corelib_src}

Error message

Cannot find System.Private.CoreLib.dll at {corelib_src}

What it means

Raised in superpmi_collect_setup.py for the 'corelib' collection when input_directory does not contain System.Private.CoreLib.dll. This collection is a single-assembly crossgen2 run over that exact DLL.

Source

Thrown at src/coreclr/scripts/superpmi_collect_setup.py:668

                              if os.path.isfile(os.path.join(core_root_dir, item)) and (item.endswith(".dll") or item.endswith(".exe"))]

        if coreclr_args.collection_name == "smoke_tests":
            if coreclr_args.collection_type != "nativeaot":
                raise RuntimeError("Collection 'smoke_tests' is only available for 'nativeaot' collections.")

        if coreclr_args.collection_name == "corelib":
            # corelib is a single-assembly crossgen2 collection over a pre-built
            # System.Private.CoreLib.dll. The YAML routes InputDirectory to:
            #   - the wasm-built corelib bin dir (artifacts/bin/coreclr/browser.wasm.Release/IL)
            #     for wasm cross-target collections, or
            #   - the host release Core_Root for non-cross-target collections.
            # Build a custom one-file input directory so the partitioning logic produces
            # exactly one helix partition. The references crossgen2 needs are resolved
            # out of the release Core_Root that's part of the correlation payload (see
            # run_crossgen2 in superpmi.py, which passes -r:<core_root>\System.*.dll etc.).
            corelib_src = os.path.join(coreclr_args.input_directory, "System.Private.CoreLib.dll")
            if not os.path.isfile(corelib_src):
                raise RuntimeError("Cannot find System.Private.CoreLib.dll at " + corelib_src)
            corelib_input_dir = os.path.join(workitem_payload_directory, "corelib_input")
            os.makedirs(corelib_input_dir, exist_ok=True)
            copy_files(coreclr_args.input_directory, corelib_input_dir, [corelib_src])
            coreclr_args.input_directory = corelib_input_dir

        partition_files(coreclr_args.input_directory, input_artifacts, coreclr_args.max_size, exclude_directories,
                        exclude_files)

    # Set variables
    print('Setting pipeline variables:')
    set_pipeline_variable("CorrelationPayloadDirectory", correlation_payload_directory)
    set_pipeline_variable("WorkItemDirectory", workitem_payload_directory)
    set_pipeline_variable("InputArtifacts", input_artifacts)
    set_pipeline_variable("Python", ' '.join(get_python_name()))
    set_pipeline_variable("Architecture", arch)
    set_pipeline_variable("Queue", helix_queue)
    set_pipeline_variable("HelixSourcePrefix", helix_source_prefix)
    set_pipeline_variable("MchFileTag", coreclr_args.mch_file_tag)

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Verify the expected path exists: `ls <input_directory>/System.Private.CoreLib.dll`.
  2. Point --input_directory at the Core_Root (or the wasm IL dir) that actually contains the DLL.
  3. Ensure the build that produces System.Private.CoreLib.dll completed before this step.
  4. Check the YAML routing logic in the comments above the check for the correct dir per wasm/host.

Example fix

// before
# --input_directory /wrong/path -> raises [194]
// after
--input_directory <core_root_or_wasm_il_dir_containing_System.Private.CoreLib.dll>
Defensive patterns

Strategy: validation

Validate before calling

import os
corelib = os.path.join(input_directory, 'System.Private.CoreLib.dll')
if collection_name == 'corelib' and not os.path.isfile(corelib):
    raise SystemExit(f'missing {corelib}; point --input_directory at the Core_Root / wasm IL dir')

Type guard

def corelib_present(input_directory: str) -> bool:
    import os
    return os.path.isfile(os.path.join(input_directory, 'System.Private.CoreLib.dll'))

Try / catch

try:
    main(args)
except RuntimeError as e:
    if 'System.Private.CoreLib.dll' in str(e):
        args.input_directory = locate_core_root(); main(args)

Prevention

When it happens

Trigger: collection_name=='corelib' and os.path.isfile(os.path.join(input_directory,'System.Private.CoreLib.dll')) is false.

Common situations: input_directory points at the wrong bin folder (e.g., IL subfolder mismatch between wasm and host layouts); the Core_Root was not built/copied; YAML InputDirectory template produced the wrong path.

Related errors


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