Skip to content

Allow unresolved symlinks inside a tree artifactΒ #15454

@GWLeal

Description

@GWLeal

Hello,

I've noticed some strange behavior regarding how bazel evaluates invalid symlinks.

UC1:
When I declare an invalid symlink, in a custom rule, and I build a bazel target of that kind bazel prints out the message:
Error in declare_symlink: actions.declare_symlink() is not allowed; use the --experimental_allow_unresolved_symlinks command line option
As expected when the suggested option is added the target builds successfully.

UC2:
However when I declare a folder and add a invalid symlink in that folder I get:
ERROR: (...): Failed to resolve relative path invalid_symlink inside TreeArtifact (...) The associated file is either missing or is an invalid symlink.
Adding the --experimental_allow_unresolved_symlinks does not work in this case.

This seems like inconsistent behavior. Also it is pretty common to pack build artifacts that contain invalid symlinks that will only become valid when the package is installed on the intended target.
I looked in the documentation and did not find a way to circumvent the issue.

I prepared a minimal working example to replicate the problem: https://github.com/GWLeal/bazel_invalid_symlinks_ex

UC1:
bazel build //test:symlink_test

UC2:
bazel build //test:dir_symlink_test

I'm currently using bazel version 5.1.1

Thank you in advance for taking the time to look into this :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions