Skip to content

fix(build): rerun rclrs's build script when AMENT_PREFIX_PATH changes - #718

Open
rosterloh wants to merge 1 commit into
ros2-rust:mainfrom
rosterloh:build/rerun-on-ament-prefix-path
Open

rosterloh wants to merge 1 commit into
ros2-rust:mainfrom
rosterloh:build/rerun-on-ament-prefix-path

Conversation

@rosterloh

@rosterloh rosterloh commented Sep 26, 2026 •

Copy link
Copy Markdown

rclrs/build.rs adds a link search path for every prefix in AMENT_PREFIX_PATH, but only declares ROS_DISTRO as a rerun trigger, so Cargo keeps the paths from the first build. After sourcing a workspace that adds an interface package, the build fails with:

ld: library not found for -lmy_interfaces__rosidl_typesupport_c

until you cargo clean -p rclrs -p rosidl_runtime_rs. This PR declares AMENT_PREFIX_PATH as a rerun trigger next to where it is read.

Companion to ros2-rust/rosidl_runtime_rs#31, which does the same there.

This pull request was assisted by: Claude:claude-opus-5-5

rosterloh added a commit to rosterloh/ros2_rust that referenced this pull request Nov 23, 2026
build.rs emits a rustc-link-search path for every prefix from
get_search_paths(), which reads AMENT_PREFIX_PATH, but declares only
ROS_DISTRO as a rerun trigger. Once a build script emits any rerun-if line,
Cargo reruns it only for the listed triggers, so the search paths stay
whatever they were on the first build.

Reproduced with a crate that depends on rclrs 0.8.0 and ros-env 0.3.0: build
it, source a workspace that adds an interface package, and rebuild without
`cargo clean`. ros-env declares rerun-if-env-changed=AMENT_PREFIX_PATH, so it
reruns and compiles the new package in, with a #[link] to its typesupport
library. rclrs and rosidl_runtime_rs, which emit the per-prefix link search
paths, do not rerun, so the final link fails with
"library not found for -l<pkg>__rosidl_typesupport_c" although the library is
on the new prefix. With this change the rebuild links.

Assisted-by: Claude Code:claude-opus-5-5
@rosterloh

Copy link
Copy Markdown
Author

@esteve do you think you might be able to review this? It has been hanging around for quite some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant