Skip to content

Allow repositories that they depend on the contents of files/directories on the local file system #20952

@lberki

Description

@lberki

Description of the feature request:

An important use case for Starlark repositories is configuring the build for the local machine.

This sometimes requires reading files, calling readdir(), i.e. interacting with the local file system. In some cases, it's desirable that the repository is not re-fetched if the local state changes (if it's expensive to do so), but in some other case, it is and we currently don't provide a good mechanism to do so:

  • rctx.read() and friends can only declare dependencies on files in other repositories
  • local_repository() and new_local_repository() are only invalidated when the top-level directory of the repository changes and they can't pull in individual files (this matters for large directories e.g. /etc). The rationale behind the first limitation is that one would glob() in the repository and declare dependencies on the files below the first level that way, but that doesn't work for other repository rules.

The only workaround at the moment is to declare a dependency on an environment variable that always changes, which has other undesirable effects (see #20951).

There is a separate, ancient feature request to always re-run a repository rule (#3041) but I think that's dangerous because it results in sloppiness with declaring dependencies.

Which category does this issue belong to?

No response

What underlying problem are you trying to solve with this feature?

No response

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

No response

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?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)team-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.type: feature request

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions