How to provide a MODULE.bazel file to local_path_override?

513 views Asked by At

I search for a way to provide a MODULE.bazel file to local_path_override.

Example:

MODULE.bazel:

bazel_dep(name = "fmt", version = "10.1.1")

local_path_override(
    module_name = "fmt",
    # Local copy of https://github.com/fmtlib/fmt at some newer commit as 10.1.1
    # Does not have a MODULE.bazel file
    path = "../third_party/fmt",
)

What I actually want to do is something like this:

bazel_dep(name = "fmt", version = "10.1.1")

local_path_override(
    module_name = "fmt",
    module_file = "//:fmt.MODULE.bazel", # provide a MODULE.bazel file here
    # Local copy of https://github.com/fmtlib/fmt at some newer commit as 10.1.1
    # Does not have a MODULE.bazel file
    path = "../third_party/fmt",
)

I want to provide a MODULE.bazel from outside, since the local copy does not have one. Please note that the attribute module_file does not exist and was just an idea how I could imagine how this could work.

Using a WORKSPACE approach it worked this way:

new_local_repository(
    name = "fmt",
    build_file = "//:fmt.BUILD",
    path = "../third_party/fmt",
)

I search for something similar in the Bzlmod world.

I was also thinking if I could use archive_override providing the MODULE.bazel file as a patch. It seems that archive_override can handle file:// URLs, but as for as I understand this does not work with relative path names (such as ../third_party/fmt) and would require me to define an absolute system specific path.

BTW: I am using Bazel 6.3.2

0

There are 0 answers