-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Description of the feature request:
Please add support for relative paths or %workspace% relative paths to the --override_module flag.
Currently the --override_module flag only accepts absolute paths. However, such absolute paths are usually only valid on a specific machines and cannot usually be checked into a project's .bazelrc configuration file.
The following sequence of commands illustrates the issue.
$ git clone https://github.com/tweag/rules_nixpkgs.git
$ cd rules_nixpkgs/toolchains/java
$ bazel build //... --enable_bzlmod --deleted_packages=docs --override_module=rules_nixpkgs_core=../../core
Starting local Bazel server and connecting to it...
ERROR: While parsing option --override_module=rules_nixpkgs_core=../../core: Module override directory must be an absolute path
$ bazel build //... --enable_bzlmod --deleted_packages=docs --override_module=rules_nixpkgs_core=%workspace%/../../core
ERROR: While parsing option --override_module=rules_nixpkgs_core=%workspace%/../../core: Module override directory must be an absolute path
$ bazel build //... --enable_bzlmod --deleted_packages=docs --registry=file://%workspace%/../../registry --registry=https://bcr.bazel.build
...
INFO: Build completed successfully, 1 total action
As shown here, a local registry can be used as a workaround to this limitation at the moment. However, this requires a lot of boilerplate to set up.
What underlying problem are you trying to solve with this feature?
The need for this feature occurs when a repository holds multiple Bazel modules that depend on each other. For example, the rules_nixpkgs repository contains multiple Bazel modules such as rules_nixpkgs_core or rules_nixpkgs_java. In this case rules_nixpkgs_java depends on rules_nixpkgs_core. However, we cannot use a local_path_override (which supports relative paths) in rules_nixpkgs_java's MODULE.bazel file, because rules_nixpkgs_java is intended to be used as a dependency to other Bazel modules, i.e. it is not a root module.
To be able to build/test rules_nixpkgs_java on CI, we need to be able to check-in a configuration into the repository that points rules_nixpkgs_java to the neighboring rules_nixpkgs_core.
Which operating system are you running Bazel on?
Ubuntu 22.04
What is the output of bazel info release?
release 6.0.0- (@Non-Git)
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
Using the Nix shell contained in the rules_nixpkgs repository.
What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?
n/a
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
This question was discussed in the rules author SIG meeting of February 21st 2023. cc @Wyverald
Relatedly, override_repository seems to have the same limitation and may be worth extending in the same way.