{"record":{"id":"b24642666e7dd750","repo":"dotnet/runtime","slug":"final-mch-file-failed-to-be-generated","errorCode":null,"errorMessage":"Final mch file failed to be generated.","messagePattern":"Final mch file failed to be generated\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/superpmi.py","lineNumber":1420,"sourceCode":"            else\n                # copy/move base file to final file\n            del <s_baseFailMclFile>\n        \"\"\"\n\n        logging.info(\"Cleaning MCH file\")\n\n        command = [self.superpmi_path, \"-p\", \"-f\", self.base_fail_mcl_file, self.base_mch_file, self.jit_path]\n        run_and_log(command)\n\n        if is_nonzero_length_file(self.base_fail_mcl_file):\n            command = [self.mcs_path, \"-strip\", self.base_fail_mcl_file, self.base_mch_file, self.final_mch_file]\n            run_and_log(command)\n        else:\n            # Ideally we could just rename this file instead of copying it.\n            shutil.copy2(self.base_mch_file, self.final_mch_file)\n\n        if not os.path.isfile(self.final_mch_file):\n            raise RuntimeError(\"Final mch file failed to be generated.\")\n\n        if not self.coreclr_args.skip_cleanup:\n            if os.path.isfile(self.base_fail_mcl_file):\n                os.remove(self.base_fail_mcl_file)\n                self.base_fail_mcl_file = None\n            if os.path.isfile(self.base_mch_file):\n                os.remove(self.base_mch_file)\n                self.base_mch_file = None\n\n    def __copy_to_final_mch_file__(self):\n        \"\"\" When not cleaning the MCH file, copy the base MCH file to the final MCH file location.\n\n        Notes:\n            # copy/move base file to final file\n            del <s_baseFailMclFile>\n        \"\"\"\n\n        logging.info(\"Copy base MCH file to final MCH file\")","sourceCodeStart":1402,"sourceCodeEnd":1438,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/scripts/superpmi.py#L1402-L1438","documentation":"Raised by SuperPMICollect.__create_clean_mch_file__ in superpmi.py after the clean step. Depending on whether base_fail_mcl_file is non-empty it either runs `mcs -strip` or copies base.mch to final_mch_file; then it asserts os.path.isfile(self.final_mch_file) and raises if the final MCH is missing.","triggerScenarios":"Running `superpmi.py collect ... --clean` where the strip step failed or the shutil.copy2 of base.mch to the final path failed, leaving final_mch_file absent.","commonSituations":"mcs -strip failed on the failure MCL; out of disk space; the final_mch_file directory was removed mid-run; permission error on the output path; base.mch itself was missing going into the copy.","solutions":["Re-run with -log_level debug and inspect the superpmi/mcs commands run during the clean step.","Ensure the output directory (-output_mch_path parent, or cwd) exists and is writable with enough disk space.","Verify base.mch existed before the clean step (i.e. the prior merge succeeded); if not, fix the merge first.","Drop --clean to fall back to the copy path (__copy_to_final_mch_file__) and confirm output is produced."],"exampleFix":"// before\npython superpmi.py collect 'cmd' --clean   # strip/copy failed -> 'Final mch file failed to be generated.'\n// after\npython superpmi.py collect 'cmd' --clean -log_level debug   # inspect, free disk / fix mcs, then re-run","handlingStrategy":"validation","validationCode":"import os\nif not os.path.isfile(final_mch_file):\n    raise SystemExit(f\"Final MCH not generated at {final_mch_file}; ensure disk space, permissions, and a valid base.mch\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the merge step succeeded (base.mch exists) before relying on the clean step.","Ensure the output directory is writable and has enough free space before running collect --clean."],"tags":["superpmi","collect","clean","mch","python"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}