rules_ros2 icon indicating copy to clipboard operation
rules_ros2 copied to clipboard

Fix RMW_LIBRARY_PATH define in presence of transitions

Open lalten opened this issue 10 months ago • 5 comments

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.

lalten avatar Feb 25 '25 10:02 lalten

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?

mvukov avatar Feb 26 '25 20:02 mvukov

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 image

and fixed it by using ../ instead of $(rootpath in https://github.com/mvukov/rules_ros2/pull/446/commits/00f4065ceb624c82f1eb1519dc46f52af99b804c

lalten avatar Mar 01 '25 15:03 lalten

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.

mvukov avatar Mar 05 '25 21:03 mvukov

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.

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

lalten avatar Mar 06 '25 08:03 lalten

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.

mvukov avatar Mar 12 '25 19:03 mvukov