dotnet/runtime · error · RuntimeError
Couldn't create git diff
Error message
Couldn't create git diff
What it means
Raised during asmdiffs when `--git_diff` is set (superpmi.py:2515-2527). After textual diffs are found, the script runs `git diff --output=<asm_diffs.diff> --no-index -- <base_dir> <diff_dir>`; git returns 0 for no differences and 1 for differences, both acceptable. Any other return code raises this error, meaning the git invocation itself failed.
Source
Thrown at src/coreclr/scripts/superpmi.py:2527
ran_jit_analyze = True
if not ran_jit_analyze:
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:")
logging.info(" jit-analyze -r --base %s --diff %s", base_asm_location, diff_asm_location)
if self.coreclr_args.git_diff:
asm_diffs_location = os.path.join(asm_root_dir, "asm_diffs.diff")
git_diff_command = [ "git", "diff", "--output=" + asm_diffs_location, "--no-index", "--", base_asm_location, diff_asm_location ]
git_diff_time = time.time() * 1000
git_diff_proc = subprocess.Popen(git_diff_command, stdout=subprocess.PIPE)
git_diff_proc.communicate()
git_diff_elapsed_time = round((time.time() * 1000) - git_diff_time, 1)
git_diff_return_code = git_diff_proc.returncode
if git_diff_return_code == 0 or git_diff_return_code == 1: # 0 means no differences and 1 means differences
logging.info("Created git diff file at %s in %s ms", asm_diffs_location, git_diff_elapsed_time)
logging.info("-------")
else:
raise RuntimeError("Couldn't create git diff")
else:
logging.warning("No textual differences. Is this an issue with coredistools?")
# If we are not specifying custom metrics then print a summary here, otherwise leave the summarization up to jit-analyze.
if self.coreclr_args.metrics is None:
base_diff_sizes = [(int(r["Base ActualCodeBytes"]), int(r["Diff ActualCodeBytes"])) for r in diffs]
(num_size_improvements, num_size_regressions, num_size_same, byte_improvements, byte_regressions) = calculate_size_improvements_regressions(base_diff_sizes)
num_diffs_str = "{:,d} contexts with diffs".format(len(diffs))
logging.info("{} ({:,d} size improvements, {:,d} size regressions, {:,d} same size)".format(
num_diffs_str,
num_size_improvements,
num_size_regressions,
num_size_same,
byte_improvements,
byte_regressions))
View on GitHub (pinned to 290d5ab72c)
Solutions
- Verify `git` is installed and on PATH (`git --version`).
- Check that the asm output root directory is writable so `--output=` can create the diff file.
- Drop `--git_diff` if you do not need the `.diff` artifact (the asm diff analysis still runs without it).
Example fix
// before superpmi.py asmdiffs --git_diff -mch_files foo.mch ... # in a container without git // after superpmi.py asmdiffs -mch_files foo.mch ... # omit --git_diff, or apt-get install git first
Defensive patterns
Strategy: try-catch
Validate before calling
import shutil
if args.git_diff and not shutil.which('git'):
raise SystemExit('git not found on PATH; cannot honor --git_diff') Try / catch
try:
# ...the asmdiffs flow that may run git diff
except RuntimeError as e:
if "Couldn't create git diff" in str(e):
logging.error('git diff failed; install git or drop --git_diff')
# degrade gracefully by continuing without the .diff artifact
else:
raise Prevention
- Prefer omitting --git_diff unless you need the raw diff artifact.
- Ensure git is installed in CI images that run asmdiffs.
When it happens
Trigger: Running `superpmi.py asmdiffs --git_diff ...` where the `git diff --no-index` subprocess exits with a code other than 0 or 1. Common when git is not installed/on PATH, the output path is unwritable, or git itself errors out.
Common situations: Running in a minimal container/CI image without git installed; the asm_diffs.diff output location is on a read-only mount; the base/diff asm directories do not exist or are inaccessible to git.
Related errors
- Core_Root not set properly
- Specified -base_jit_path does not point to a file
- Couldn't determine current git hash
- Couldn't determine newest 'main' git hash
- Couldn't determine baseline git hash
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/ddd5b2842ea1fc19.
Report an issue: GitHub.