{"record":{"id":"ddd5b2842ea1fc19","repo":"dotnet/runtime","slug":"couldn-t-create-git-diff","errorCode":null,"errorMessage":"Couldn't create git diff","messagePattern":"Couldn't create git diff","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/superpmi.py","lineNumber":2527,"sourceCode":"                                ran_jit_analyze = True\n\n                        if not ran_jit_analyze:\n                            logging.info(\"jit-analyze not found on PATH. Generate a diff analysis report by building jit-analyze from https://github.com/dotnet/jitutils and running:\")\n                            logging.info(\"    jit-analyze -r --base %s --diff %s\", base_asm_location, diff_asm_location)\n\n                        if self.coreclr_args.git_diff:\n                            asm_diffs_location = os.path.join(asm_root_dir, \"asm_diffs.diff\")\n                            git_diff_command = [ \"git\", \"diff\", \"--output=\" + asm_diffs_location, \"--no-index\", \"--\", base_asm_location, diff_asm_location ]\n                            git_diff_time = time.time() * 1000\n                            git_diff_proc = subprocess.Popen(git_diff_command, stdout=subprocess.PIPE)\n                            git_diff_proc.communicate()\n                            git_diff_elapsed_time = round((time.time() * 1000) - git_diff_time, 1)\n                            git_diff_return_code = git_diff_proc.returncode\n                            if git_diff_return_code == 0 or git_diff_return_code == 1: # 0 means no differences and 1 means differences\n                                logging.info(\"Created git diff file at %s in %s ms\", asm_diffs_location, git_diff_elapsed_time)\n                                logging.info(\"-------\")\n                            else:\n                                raise RuntimeError(\"Couldn't create git diff\")\n\n                    else:\n                        logging.warning(\"No textual differences. Is this an issue with coredistools?\")\n\n                    # If we are not specifying custom metrics then print a summary here, otherwise leave the summarization up to jit-analyze.\n                    if self.coreclr_args.metrics is None:\n                        base_diff_sizes = [(int(r[\"Base ActualCodeBytes\"]), int(r[\"Diff ActualCodeBytes\"])) for r in diffs]\n                        (num_size_improvements, num_size_regressions, num_size_same, byte_improvements, byte_regressions) = calculate_size_improvements_regressions(base_diff_sizes)\n\n                        num_diffs_str = \"{:,d} contexts with diffs\".format(len(diffs))\n                        logging.info(\"{} ({:,d} size improvements, {:,d} size regressions, {:,d} same size)\".format(\n                            num_diffs_str,\n                            num_size_improvements,\n                            num_size_regressions,\n                            num_size_same,\n                            byte_improvements,\n                            byte_regressions))\n","sourceCodeStart":2509,"sourceCodeEnd":2545,"githubUrl":"https://github.com/dotnet/runtime/blob/b7130aa5e416e88ac48fafe92bf56a9d64e13c97/src/coreclr/scripts/superpmi.py#L2509-L2545","documentation":"Raised in SuperPMIAsmDiffs when coreclr_args.git_diff is enabled. After textual diffs are found, it runs `git diff --output=<asm_diffs.diff> --no-index -- <base_asm> <diff_asm>` and expects exit code 0 (no diffs) or 1 (diffs present). Any other exit code (e.g. git not found, missing input dirs, usage error) triggers this RuntimeError.","triggerScenarios":"git is not installed or not on PATH; the base_asm_location or diff_asm_location directories do not exist or are not accessible; git returns 128/129 from a usage or I/O error; the --output= option is unsupported by an ancient git version.","commonSituations":"Running asm diffs in a minimal container without git; one of the two asm output trees failed to generate earlier so its path is invalid; git < 2.2 lacks the --output flag.","solutions":["Ensure git is installed and on PATH: `git --version` (need >= 2.2 for --output).","Verify both base_asm_location and diff_asm_location directories exist before enabling --git_diff.","Run the exact git diff command by hand to read the real stderr/exit code.","If git is unavailable, drop --git_diff and rely on the textual/perfscore summary instead."],"exampleFix":"# before\nsuperpmi.py asmdiffs --git_diff ...\n# after\ngit --version && ls -d <base_asm_dir> <diff_asm_dir>   # confirm prerequisites first\nsuperpmi.py asmdiffs --git_diff ...","handlingStrategy":"try-catch","validationCode":"import os, shutil, subprocess\n\n# Pre-flight for the git diff step\nif shutil.which(\"git\") is None:\n    raise SystemExit(\"git not found on PATH; cannot create --git_diff\")\nfor d in (base_asm_location, diff_asm_location):\n    if not os.path.isdir(d):\n        raise SystemExit(f\"asm dir missing: {d}\")","typeGuard":null,"tryCatchPattern":"try:\n    # ... existing git diff block ...\nexcept RuntimeError as e:\n    if \"Couldn't create git diff\" in str(e):\n        logging.warning(\"git diff failed; continuing without asm_diffs.diff\")\n        # Optionally fall back to a textual-only summary.\n    else:\n        raise","preventionTips":["Ensure git >= 2.2 is installed (needed for the --output flag).","Only enable --git_diff when both asm trees are known to exist.","In CI images, install git alongside coredistools.","Treat the git diff as optional — the textual/perfscore summary is still produced without it."],"tags":["superpmi","asm-diffs","git","subprocess"],"analyzedSha":"b7130aa5e416e88ac48fafe92bf56a9d64e13c97","analyzedAt":"2026-08-07T06:17:13.108Z","schemaVersion":2},"datasetVersion":"2026-08-07T15:17:06.553Z"}