mvukov / rules_ros

Build ROS (1) with Bazel
Apache License 2.0
24 stars 12 forks source link

Using rules_ros via bzlmod results in `invalid label for module extension found` #32

Closed hofbi closed 3 months ago

hofbi commented 4 months ago

I am adding rules_ros via bzlmod as follows

archive_override(
    module_name = "rules_ros",
    integrity = "sha256-g6LeMe0p/Q9/JTppfPs8G2OIGfU2vwk42262pVrsN4Q=",
    strip_prefix = "rules_ros-049418ec41397080ec2fdff1e76eb7e95d9a0d57",
    urls = "https://github.com/mvukov/rules_ros/archive/049418ec41397080ec2fdff1e76eb7e95d9a0d57.tar.gz",
)

and end up with ERROR: Error computing the main repository mapping: invalid label for module extension found at @@rules_ros~//:MODULE.bazel:56:23: no repo visible as '@rules_python' here

So somehow this line seems to be a problem.

finn-ball commented 4 months ago

What happens if you flip this:

bazel_dep(name = "rules_python", version = "0.33.2", dev_dependency = True)

To this:

bazel_dep(name = "rules_python", version = "0.33.2")
hofbi commented 4 months ago

I already fail in applying the patch

diff --git a/MODULE.bazel b/MODULE.bazel
index 6279b42..28e82b5 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -14,7 +14,7 @@ bazel_dep(name = "platforms", version = "0.0.10")
 bazel_dep(name = "rules_cc", version = "0.0.9")
 bazel_dep(name = "rules_foreign_cc", version = "0.11.1")

-bazel_dep(name = "rules_python", version = "0.33.2", dev_dependency = True)
+bazel_dep(name = "rules_python", version = "0.33.2")

 non_module_ros_repositories = use_extension("//ros:extensions.bzl", "non_module_dependencies")
 use_repo(
archive_override(
    module_name = "rules_ros",
    integrity = "sha256-g6LeMe0p/Q9/JTppfPs8G2OIGfU2vwk42262pVrsN4Q=",
    strip_prefix = "rules_ros-049418ec41397080ec2fdff1e76eb7e95d9a0d57",
    urls = "https://github.com/mvukov/rules_ros/archive/049418ec41397080ec2fdff1e76eb7e95d9a0d57.tar.gz",
    patches = ["//:foo.patch"],
)

Error in patch: Error applying patch ...foo.patch: Cannot find file to patch (near line 3), old file name (a/MODULE.bazel) doesn't exist, new file name (b/MODULE.bazel) doesn't exist.

finn-ball commented 4 months ago

I've forgotten the argument off the top of my head you may need to add to the patch command so try and delete the a/ and b/ from the file names.

It may be easier if you create a small repository example.

hofbi commented 4 months ago

Good point. I might contribute an example to https://github.com/mvukov/rules_ros/tree/main/examples which actually consumes rules_ros as module

finn-ball commented 4 months ago

rules_boost has a decent workflow here where they consume their own repository as a local_override in the test/MODULE.bazel

https://github.com/nelhage/rules_boost/tree/master/test

hofbi commented 4 months ago

Good to know. Looks like I already used that to contribute https://github.com/pybind/pybind11_bazel/pull/87.

Btw, you were right. Removing dev dependency fixed the issue. I could reproduce it with the example I am contributing with https://github.com/mvukov/rules_ros/pull/33

hofbi commented 4 months ago

Regarding the patch failure, you can use https://github.com/hofbi/rules_ros/tree/patch-fail to reproduce.

# Checkout the branch
cd examples/bzlmod
bazel build //...
# See the patch failure
mvukov commented 3 months ago

Fixed via #43?