bazelbuild/bazel · error · RuntimeError

Runfiles resolved {path} to {binary} but the file does not e

Error message

Runfiles resolved {path} to {binary} but the file does not exist

What it means

Raised by the proguard wrapper when Rlocation() succeeds — returning a concrete filesystem path — but that path does not exist on disk. So the runfiles metadata knows the entry, yet the file itself is missing, meaning the manifest and the filesystem are out of sync.

Source

Thrown at tools/build_defs/proguard/wrapper.py:52

    r: The Runfiles object to use for the lookup.
    path: The path of the binary being found.

  Returns:
    The full path to the binary.

  Raises:
    RuntimeError: If the path is not present in the runfiles, or if the adjusted
    path does not
    exist on the filesystem.
  """

  if platform.system() == "Windows":
    path = path + ".exe"
  binary = r.Rlocation(path)
  if not binary:
    raise RuntimeError(f"Runfiles failed to resolve {path}")
  elif not os.path.exists(binary):
    raise RuntimeError(
        f"Runfiles resolved {path} to {binary} but the file does not exist"
    )
  return binary


def apply_proguard(srcs, deps, proguard_spec, output_jar):
  """Call proguard on the given source jars with the spec.

  Args:
    srcs: The source jars to be modified.
    deps: Dependency jars needed to resolve the source jars.
    proguard_spec: The path to the proguard spec file describing what
      modifications to make.
    output_jar: The path to write the resulting modified jar file to.

  Raises:
    RuntimeError: When the proguard binary fails, includes the stdout and
    stderr.

View on GitHub (pinned to e6e199d060)

Solutions

  1. Rebuild/rerun the wrapper target so runfiles and the manifest are regenerated together (bazel run of the tool).
  2. Check the resolved path printed in the message ('Runfiles resolved ... to ...') and confirm its parent directory exists.
  3. If the path points into an external repo, force a refetch (bazel sync or touch the WORKSPACE entry) so the artifact is materialized.
Defensive patterns

Strategy: retry

Validate before calling

binary = r.Rlocation(path)
assert binary, 'Rlocation failed for %s' % path
assert os.path.exists(binary), 'runfiles entry stale for %s -> %s' % (path, binary)

Try / catch

try:
    run_tool()
except RuntimeError as e:
    if 'does not exist' in str(e):
        rebuild_and_retry()  # regenerate runfiles via bazel run
    raise

Prevention

When it happens

Trigger: os.path.exists(binary) is false after a successful Rlocation: stale runfiles manifest from a previous build, a runfiles tree where the file was pruned, or a symlinked runfiles dir pointing at a cleaned output base.

Common situations: Reusing an old runfiles manifest after 'bazel clean' or after the producing target was renamed; external repo fetched lazily and the artifact not yet materialized; sandboxing discarding files referenced only via manifest.

Related errors


AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14). Data as JSON: /api/errors/c2502a6297bab6c7. Report an issue: GitHub.