Fix RMW_LIBRARY_PATH define in presence of transitions
This fixes the below error
unknown file: Failure
C++ exception with description "Failed to deserialize ROS message.: failed to load shared library 'external/ros2_rmw_cyclonedds/librmw_cyclonedds.so' due to dlopen error: external/ros2_rmw_cyclonedds/librmw_cyclonedds.so: cannot open shared object file: No such file or directory, at external/ros2_rcutils/src/shared_library.c:96, at external/ros2_rmw_implementation/rmw_implementation/src/functions.cpp:90" thrown in the test body.
Which you will get when transitions (e.g. via with_cfg.bzl) are at play, because the k8-fastbuild and friends will not be correct anymore, it has to be k8-fastbuild-ST-61f4e3852c4b or similar, depending on configuration.
Using ../ instead is always correct because of the runfiles structure at runtime.
rootpath shouldn't have k8-fastbuild in it AFAIK.
We touched this in
- https://github.com/mvukov/rules_ros2/pull/65 and then in
- https://github.com/mvukov/rules_ros2/pull/66
I'd like to learn more about your usecase.
BTW, do you patch rmw_implementation with_cfg.bzl locally?
I added a failing test in https://github.com/mvukov/rules_ros2/pull/446/commits/ca7da17e6b480bf79fdf24614f4afcc5475e7f87:
https://github.com/mvukov/rules_ros2/actions/runs/13606301154/job/38038169533?pr=446#step:5:61
and fixed it by using ../ instead of $(rootpath in https://github.com/mvukov/rules_ros2/pull/446/commits/00f4065ceb624c82f1eb1519dc46f52af99b804c
Would --nolegacy_external_runfiles help in the first place (mentioned in #65 )? (that is a recommended flag, we should have it in .bazelrc eventually) . With that flag I think we should just get ../ros2_rmw_cyclonedds/librmw_cyclonedds.so.
Would
--nolegacy_external_runfileshelp in the first place (mentioned in #65 )? (that is a recommended flag, we should have it in .bazelrc eventually) . With that flag I think we should just get../ros2_rmw_cyclonedds/librmw_cyclonedds.so.
True, this does indeed help. But requiring this to be set is a hard sell to downstream consumers who may have a lot of migration work ahead of them to support this flag being flipped -- especially when just using ../ also makes this work regardless of --(no)legacy_external_runfiles
We have a number of flags in .bazelrc without this repo can't work. I'm fine to declare --nolegacy_external_runfiles as a recommended one referencing this PR. --nolegacy_external_runfiles is a nice perf improvement as it reduces the number of files in runfiles folder.