dotnet/runtime · error · RuntimeError
Couldn't determine current git hash
Error message
Couldn't determine current git hash
What it means
Raised by determine_base_jit when 'git rev-parse HEAD' returns a nonzero exit code while running inside the runtime repo root (ChangeDir to runtime_repo_location). The current hash identifies the diff-side commit; without it, baseline computation cannot proceed. A nonzero code means git is unavailable, the directory is not a git repo, or the repo is in a broken state.
Solutions
- Confirm runtime_repo_location is a valid git clone: run 'git -C <runtime_repo_location> rev-parse HEAD' and ensure it succeeds.
- Ensure git is installed and on PATH in the execution environment.
- Clone the runtime repo via git rather than extracting a tarball so .git history exists.
- Pass --git_hash <sha> explicitly to skip the rev-parse step if you know the current commit.
Example fix
// before
command = ["git", "rev-parse", "HEAD"]
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
stdout_git_rev_parse, _ = proc.communicate()
if proc.returncode != 0:
raise RuntimeError("Couldn't determine current git hash")
// after (fix invocation)
git -C <runtime_repo_location> rev-parse HEAD # must succeed
# Or pass the hash explicitly:
python superpmi.py asmdiff --git_hash <sha> ... Defensive patterns
Strategy: validation
Validate before calling
import subprocess, shutil
def validate_git_head(repo_location):
if shutil.which('git') is None:
raise RuntimeError('git is not installed or not on PATH')
proc = subprocess.run(['git', '-C', repo_location, 'rev-parse', 'HEAD'], capture_output=True)
if proc.returncode != 0:
raise RuntimeError(f"git rev-parse HEAD failed in {repo_location}: {proc.stderr.decode('utf-8','replace').strip()}")
return proc.stdout.decode('utf-8').strip() Prevention
- Ensure runtime_repo_location is a real git clone (not a tarball extract).
- Keep git installed and on PATH in CI containers.
- Pass --git_hash explicitly to bypass rev-parse when history is known.
When it happens
Trigger: subprocess.Popen(['git','rev-parse','HEAD']) runs and proc.returncode != 0, inside the runtime_repo_location. Happens when runtime_repo_location is not a git checkout, git is not installed/on PATH, the .git directory is missing/corrupt, or HEAD is unborn (empty repo after init with no commits).
Common situations: Downloading a source tarball instead of a git clone (no .git); running in a stripped container without git; pointing --runtime_repo_location at the wrong directory; a fresh repo with no commits.
Related errors
- Couldn't determine baseline git hash
- Couldn't determine list of JIT changes starting with…
- Couldn't determine newest 'main' git hash
- Couldn't create git diff
- No JIT changes found starting with baseline hash
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/98769d8cd9289283.
Report an issue: GitHub.
Appendix: source
Thrown at src/coreclr/scripts/superpmi.py:4868
# We cache baseline jits under the following directory. Note that we can't create the full directory path
# until we know the baseline JIT hash.
default_basejit_root_dir = os.path.join(coreclr_args.spmi_location, "basejit")
# Do all the remaining commands, including a number of 'git' commands including relative paths,
# from the root of the runtime repo.
with ChangeDir(coreclr_args.runtime_repo_location):
if coreclr_args.git_hash is None:
command = [ "git", "rev-parse", "HEAD" ]
logging.debug("Invoking: %s", " ".join(command))
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
stdout_git_rev_parse, _ = proc.communicate()
return_code = proc.returncode
if return_code == 0:
current_hash = stdout_git_rev_parse.decode('utf-8').strip()
logging.debug("Current hash: %s", current_hash)
else:
raise RuntimeError("Couldn't determine current git hash")
else:
current_hash = coreclr_args.git_hash
if coreclr_args.base_git_hash is None:
# We've got the current hash; figure out the baseline hash.
# First find the newest hash for any branch matching */main.
command = [ "git", "branch", "-r", "--sort=-committerdate", "-v", "--list", "*/main" ]
logging.debug("Invoking: %s", " ".join(command))
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
stdout_git_main_branch, _ = proc.communicate()
return_code = proc.returncode
if return_code != 0:
raise RuntimeError("Couldn't determine newest 'main' git hash")
main_hash = stdout_git_main_branch.decode('utf-8').strip().split()[1]
# Get the merge-base between the newest main and our current rev
command = [ "git", "merge-base", current_hash, main_hash ]View on GitHub (pinned to 60108ba66e)