{"record":{"id":"0e7387e52bca558d","repo":"dotnet/runtime","slug":"mch-file-failed-to-be-generated-at-s","errorCode":null,"errorMessage":"MCH file failed to be generated at: %s","messagePattern":"MCH file failed to be generated at: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/superpmi.py","lineNumber":1368,"sourceCode":"            raise RuntimeError(\"No .mc files generated.\")\n\n    def __merge_mc_files__(self):\n        \"\"\" Merge the mc files that were generated\n\n        Notes:\n            mcs -merge <s_baseMchFile> <s_tempDir>\\\\*.mc -recursive -dedup -thin\n\n        \"\"\"\n\n        logging.info(\"Merging MC files\")\n\n        pattern = os.path.join(self.temp_location, \"*.mc\")\n\n        command = [self.mcs_path, \"-merge\", self.base_mch_file, pattern, \"-recursive\", \"-dedup\", \"-thin\"]\n        run_and_log(command)\n\n        if not os.path.isfile(self.base_mch_file):\n            raise RuntimeError(\"MCH file failed to be generated at: %s\" % self.base_mch_file)\n\n        # All the individual MC files are no longer necessary, now that we have\n        # merged them into the base.mch. Delete them.\n        if not self.coreclr_args.skip_cleanup:\n            mc_files = [os.path.join(self.temp_location, item) for item in os.listdir(self.temp_location) if item.endswith(\".mc\")]\n            for item in mc_files:\n                os.remove(item)\n\n    def __merge_mch_files__(self):\n        \"\"\" Merge MCH files in the mch_files list. This is only used with the `--merge_mch_files` argument.\n\n        Notes:\n            mcs -concat <s_baseMchFile> [self.coreclr_args.mch_files]\n\n        \"\"\"\n\n        logging.info(\"Merging MCH files\")\n","sourceCodeStart":1350,"sourceCodeEnd":1386,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/scripts/superpmi.py#L1350-L1386","documentation":"Raised in `__merge_mc_files__` (superpmi.py:1367-1368) after running `mcs -merge <base.mch> <temp>/*.mc -recursive -dedup -thin`. If the expected base MCH file is not present on disk after the merge command, the merge step failed. `run_and_log` does not itself raise on non-zero exit, so this post-check is the failure signal.","triggerScenarios":"The mcs tool crashed or returned an error during the `-merge` operation, leaving no base_mch_file behind. Causes: corrupt/empty input `.mc` files, a broken/missing mcs binary, insufficient disk space, or a permission error writing the MCH.","commonSituations":"The preceding collection produced zero-length or corrupt `.mc` files (see error 163 territory); mcs version mismatch with the runtime build; disk full on the temp drive during a large merge.","solutions":["Inspect the mcs `-merge` command output logged just before this error for the underlying mcs error/return code.","Confirm the `.mc` files in temp_location are non-empty and valid before merging.","Ensure the mcs binary matches the runtime/JIT build and the temp directory has free disk space."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# Confirm non-empty .mc inputs and mcs exists before merging\nif not any(os.path.getsize(m) > 0 for m in glob.glob(temp + '/*.mc')):\n    raise SystemExit('No non-empty .mc files to merge.')\nif not shutil.which('mcs') and not os.path.isfile(mcs_path):\n    raise SystemExit('mcs tool not found; build the runtime first.')","typeGuard":null,"tryCatchPattern":"try:\n    collection.__merge_mc_files__()\nexcept RuntimeError as e:\n    if 'MCH file failed' in str(e):\n        logging.error('mcs -merge failed; check the logged mcs output and disk space.')\n    raise","preventionTips":["Check mcs merge command output for the real error code.","Ensure the temp drive has free space for large merges."],"tags":["mch","merge","superpmi","diagnostics"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}