bazelbuild/bazel · error · RuntimeError

Runfiles failed to resolve {path}

Error message

Runfiles failed to resolve {path}

What it means

Raised by the proguard wrapper tool when the runfiles library's Rlocation() returns a falsy value for the requested binary path. That means the path is not declared in the runfiles manifest/tree, so the wrapper cannot locate the proguard (or other) executable it was asked to run.

Source

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

  Args:
    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:

View on GitHub (pinned to e6e199d060)

Solutions

  1. Verify the exact runfiles path: 'workspace_name/path/to/binary' (plus '.exe' on Windows) against the runfiles manifest next to the wrapper.
  2. Add the binary to the wrapper target's data/deps so it appears in runfiles.
  3. Run the tool under bazel (bazel run / as a build action) so the runfiles manifest or tree exists; do not invoke the script directly from the source tree.

Example fix

# before
binary = GetBinary(r, "proguard")  # not a runfiles root path

# after
binary = GetBinary(r, "third_party/java/proguard/proguard")  # exact workspace-relative runfiles path
Defensive patterns

Strategy: validation

Validate before calling

runfiles_paths = set(r.List())  # or read the manifest
if path not in runfiles_paths:
    raise ValueError('%s not declared in runfiles; add it to deps' % path)

Prevention

When it happens

Trigger: Calling GetBinary with a runfiles path (with '.exe' appended on Windows) that is not among the runfiles entries — typically because the tool target is missing a data/srcs dep on the binary, or the path spelling does not match the workspace-relative runfiles path.

Common situations: Running the proguard wrapper outside bazel (no runfiles env at all); a new proguard binary added without updating the wrapper's deps; mismatched repo name so the runfiles key has a different prefix.

Related errors


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