Skip to content

command propagates RUNFILES_MANIFEST_FILE to child binaries, breaking targets with their own runfiles trees #97

Description

@manuelnaranjo

When a command wraps a binary that performs its own runfiles discovery (e.g. a py_binary from aspect_rules_py), the child binary fails to locate files in its own runfiles tree because it inherits RUNFILES_MANIFEST_FILE from the parent multirun/command process.

I created a repro repository here

The outputs are:

$ bazel run :command-that-fails
foo.__main__ loaded
RUNFILES_MANIFEST_FILE: /home/mnaranjo/.cache/bazel/_bazel_mnaranjo/738fc0b40850cb253097925d8e75c2d7/execroot/_main/bazel-out/k8-fastbuild/bin/command-that-fails.bash.runfiles_manifest
Traceback (most recent call last):
  File "/usr/local/git_tree/multirun-aspect_rules_py-repro/foo/__main__.py", line 7, in <module>
    from bar import baz
ModuleNotFoundError: No module named 'bar'
$ bazel run :command-that-works
foo.__main__ loaded
RUNFILES_MANIFEST_FILE: 
bar.baz loaded

Not sure if this is worth to fix in rules_multirun or if it's actually something to fix in aspect_rules_py or even the hermetic_launcher but I think it's worth to share with others specially given that the workaround is quite simple:

  command(
      name = "my-command",
      command = ":my-tool",
      environment = {
          "RUNFILES_MANIFEST_FILE": "",  # actual workaround
      },
  )

Note: clearing RUNFILES_DIR as well is not viable — the rules_shell wrapper that command uses internally relies on it to locate the child binary.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions