RobotLocomotion / drake-ros

Experimental prototyping (for now)
Apache License 2.0
84 stars 32 forks source link

[bazel] Unable to use workspaces with underscores in name? #348

Open EricCousineau-TRI opened 2 months ago

EricCousineau-TRI commented 2 months ago

I am debugging a performance regression in ROS 2 Debians. As I'm doing this, I'm using timeshift to backup / restore things, so I have an "old and good" install of /opt/ros/humble, and a "new and bad" install of /opt/ros/humble. I want to swap back and forth by changing the workspace path.

On latest main (955245e), the following works:

cd drake-ros/ros2_example_bazel_installed
export ROS2_DISTRO_PREFIX=/opt/ros/humble
bazel fetch @ros2//...

However, the following fails on latest main (955245e):

sudo ln -s /opt/ros/humble /opt/ros/humble_old
cd drake-ros/ros2_example_bazel_installed
export ROS2_DISTRO_PREFIX=/opt/ros/humble_old
bazel fetch @ros2//...

The failure states:

...
        File "{output_base}/external/ros2/BUILD.bazel", line 11, column 16, in <toplevel>
                share_filegroup(
        File "{output_base}/external/ros2/tools/common.bzl", line 8, column 45, in share_filegroup
                srcs = [path for path in native.glob(
Error in glob: pattern cannot be absolute

Looking at $(bazel info output_base)/external/ros2/BUILD.bazel, I see this around line 11:

share_filegroup(
    name = "ament_cmake_core_share",
    share_directories = ["/opt/ros/humble/share/ament_cmake_core", "/opt/ros/humble/share/ament_index"],
)

Somehow, we're just ignoring the user specified directory?

EricCousineau-TRI commented 2 months ago

Ah, from looking at code, looks like it's from CMAKE_PREFIX_PATH, which may be baked into the installation.

But it's not yet clear to me how we map /opt/ros/humble to _opt_ros_humble in the nominal case. Still need to find that.