Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--remote_download_toplevel does not download symlink targets of runfiles #18249

Closed
eric-skydio opened this issue Apr 28, 2023 · 3 comments
Closed
Assignees
Labels
P1 I'll work on this now. (Assignee required) team-Remote-Exec Issues and PRs for the Execution (Remote) team type: bug

Comments

@eric-skydio
Copy link

Description of the bug:

--remote_download_toplevel downloads the runfiles associated with any outputs explicitly listed on the command line, and (on Linux) constructs a runfiles tree of symlinks for them.
Unfortunately, if the runfiles is constructed with symlinks= or root_symlinks= that refer to File objects not in the files= depset of the runfiles, this process fails and the target of the symlink is not downloaded, which results in a broken symlink in the resulting runfiles tree.

This is important for us because we use root_symlinks to relocate files to keep our PYTHONPATH smaller. This works file when not using --remote_download_toplevel.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

rules.bzl

def _symlink_rule_impl(ctx):
    file = ctx.actions.declare_file("file.txt")
    executable = ctx.actions.declare_file("executable")

    ctx.actions.run_shell(
        outputs = [file],
        command = "echo 'Hello World!' > " + file.path,
    )
    ctx.actions.write(executable, "cat symlink.txt")
    return [DefaultInfo(
        runfiles = ctx.runfiles(
            symlinks = {"symlink.txt": file},
        ),
        executable = executable,
    )]

symlink_rule = rule(
    implementation = _symlink_rule_impl,
    executable = True,
    attrs = {},
)

BUILD

load(":rules.bzl", "symlink_rule")

symlink_rule(name = "symlink")

Reproduction steps:

  1. bazel run //:symlink --remote_download_toplevel --disk_cache /tmp/cache
  2. bazel clean
  3. bazel run //:symlink --remote_download_toplevel --disk_cache /tmp/cache

Which operating system are you running Bazel on?

Ubuntu 18.04

What is the output of bazel info release?

release 6.1.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

This seems to reproduce both on Bazel 5.x and the latest 7.0.0-pre*

@Pavank1992 Pavank1992 added the team-Remote-Exec Issues and PRs for the Execution (Remote) team label Apr 28, 2023
@joeleba joeleba added P1 I'll work on this now. (Assignee required) and removed untriaged labels May 2, 2023
iancha1992 pushed a commit to iancha1992/bazel that referenced this issue May 18, 2023
Fixes bazelbuild#18249.

Closes bazelbuild#18399.

PiperOrigin-RevId: 532767884
Change-Id: I7c50b2bea7b93072e601a192031c14d2c22a5713
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
Fixes bazelbuild#18249.

Closes bazelbuild#18399.

PiperOrigin-RevId: 532767884
Change-Id: I7c50b2bea7b93072e601a192031c14d2c22a5713
@william-smith-skydio
Copy link

We see a backport of the fix to this issue to 6.3.0 in #18446, but it doesn't look like that merged and as of 6.3.2 this is still broken. Is this fix expected to be backported to 6.x or do we need to wait for 7.x?

@fmeum
Copy link
Collaborator

fmeum commented Aug 9, 2023

@william-smith-skydio That's an unrelated change of mine that hasn't been merged yet.

@coeuvre
Copy link
Member

coeuvre commented Aug 9, 2023

The fix was not cherry-picked into 6.x due to conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) team-Remote-Exec Issues and PRs for the Execution (Remote) team type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants