Skip to content

Cannot symlink source directories with declare_directory #26705

@cameron-martin

Description

@cameron-martin

Description of the bug:

Source directories cannot be symlinked by using an output declared using ctx.actions.declare_directory, whereas generated directories can. This means this cannot be used as a type of hint for whether to create a file or directory symlink on Windows (see #26701).

This could be the same root cause as #12954, which is another case where source directories are not considered to be directories.

Which category does this issue belong to?

Core

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

I’ve created a reproducer here: bazel-symlink-source-dir.tar.gz

Building :generated_directory_symlink works fine, but the similar :source_directory_symlink does not, giving the following error:

Error in symlink: symlink() with "target_file" file param requires that "output" be declared as a file (did you mean to use declare_file() instead of declare_directory()?)

Which operating system are you running Bazel on?

Ubuntu

What is the output of bazel info release?

release 8.3.1

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

N/a

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

N/a

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

N/a

Have you found anything relevant by searching the web?

No

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

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    team-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: buguntriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions