Skip to content

ament: install .srv and .action definitions alongside .msg files#627

Open
xiangguomin wants to merge 1 commit into
mvukov:mainfrom
xiangguomin:fix/ament-srv-action-install
Open

ament: install .srv and .action definitions alongside .msg files#627
xiangguomin wants to merge 1 commit into
mvukov:mainfrom
xiangguomin:fix/ament-srv-action-install

Conversation

@xiangguomin
Copy link
Copy Markdown
Contributor

Summary

Fixes #626.

The IDL source loop in _create_ament_setup (ament.bzl) had an early-exit guard that silently dropped .srv and .action files from the ament share tree:

# Before
for src in idl.srcs:
    if src.extension != "msg":
        continue   # .srv and .action files never installed
    src_file = ctx.actions.declare_file(
        paths.join(prefix_path, "share", package_name, "msg", src.basename),
    )
    ...
    idl_manifest_contents.append(paths.join("msg", src.basename))

Any runtime type-introspection tool (foxglove_bridge, ros2 service call, ros2 interface show) that looks for definitions at share/<pkg>/srv/ or share/<pkg>/action/ would not find them and fall back to IDL, producing warnings like:

[WARN] no .msg definition for rcl_interfaces/srv/DescribeParameters_Request, falling back to IDL
[WARN] Could not find definition for type rcl_interfaces/srv/DescribeParameters: rcl_interfaces/srv/DescribeParameters_Request

Fix

Route each source into its matching subdirectory (msg/, srv/, action/) under share/<pkg>/ instead of hardcoding msg/ for all types:

# After
for src in idl.srcs:
    if src.extension not in ("msg", "srv", "action"):
        continue
    subdir = src.extension
    src_file = ctx.actions.declare_file(
        paths.join(prefix_path, "share", package_name, subdir, src.basename),
    )
    ...
    idl_manifest_contents.append(paths.join(subdir, src.basename))

Test

Verified by building a ros2_cpp_binary with idl_deps = ["@ros2_rcl_interfaces//:rcl_interfaces"] and confirming that share/rcl_interfaces/srv/DescribeParameters.srv (and all other .srv files) are present in the ament_setup output tree. The foxglove_bridge "Could not find definition" warnings are gone after this change.

Previously the IDL source loop guarded with `if src.extension != "msg":
continue`, so .srv and .action files were silently dropped from the
ament share tree. Any runtime type-introspection tool (foxglove_bridge,
`ros2 service call`, `ros2 interface show`) that looks for the definitions
at share/<pkg>/srv/ or share/<pkg>/action/ would not find them and fall
back to IDL, producing "Could not find definition for type" warnings.

Route each source into its matching subdirectory (msg/, srv/, action/)
under share/<pkg>/ instead of hardcoding msg/ for all types.

Fixes mvukov#626
@mvukov mvukov enabled auto-merge (squash) May 17, 2026 21:00
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.

ament_setup skips .srv and .action definitions — only .msg files are installed

3 participants