ros2 CLI prints BrokenPipeError traceback when output is piped to a command that exits early (e.g. head)

Open Beginner friendly
#1,342 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@akshat-lakhera is already working on this.

Since Oct 19, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
63/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
cli

Research direction

The issue reports a BrokenPipeError traceback when a ros2 CLI command is piped to a command such as head, but does not identify a specific file or test. Start by locating where ros2cli writes command output and checking its existing CLI tests. Done means the early-closing pipe no longer produces a traceback; add or run a regression test for that behavior.

Written by the indexing model from the issue text.

Description

bug
Generated by Generative AI

Reproduced every command and verified the analysis myself.

Operating System:

Ubuntu 26.04 LTS on WSL2 (Windows 11), kernel 6.18.33.2-microsoft-standard-WSL2, x86_64

ROS version or commit hash:

Rolling (built from source), ros2cli at f41b4273 (2026-10-16)

RMW implementation (if applicable):

No response

RMW Configuration (if applicable):

No response

Client library (if applicable):

N/A (ros2cli, pure Python CLI)

'ros2 doctor --report' output
ros2 doctor --report


   ACTION LIST
action                 : none
action server count    : 0
action client count    : 0

   ROS ENVIRONMENT
ROS environment variables        : ROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET, ROS_DISTRO=rolling
rcutils environment variables    :
rmw environment variables        :

   NETWORK CONFIGURATION


   PACKAGE VERSIONS
rqt_bag_plugins                           : latest=2.3.5, local=2.3.5
rosbag2                                   : latest=0.35.0, local=0.35.0
launch_testing_examples                   : latest=0.22.0, local=0.22.0
ros2bag                                   : latest=0.35.0, local=0.35.0
rosbag2_storage_default_plugins           : latest=0.35.0, local=0.35.0
rosbag2_storage_mcap                      : latest=0.35.0, local=0.35.0
rosbag2_compression_zstd                  : latest=0.35.0, local=0.35.0
mcap_vendor                               : latest=0.35.0, local=0.35.0
zstd_cmake_module                         : latest=0.35.0, local=0.35.0
zenoh_security_tools                      : latest=0.14.0, local=0.14.0
turtlesim                                 : latest=1.11.3, local=1.11.3
tracetools_test                           : latest=9.0.0, local=9.0.0
tracetools_launch                         : latest=9.0.0, local=9.0.0
topic_monitor                             : latest=0.38.0, local=0.38.0
pendulum_control                          : latest=0.38.0, local=0.38.0
tlsf_cpp                                  : latest=1.0.1, local=1.0.1
geometry2                                 : latest=0.46.4, local=0.46.4
tf2_tools                                 : latest=0.46.4, local=0.46.4
tf2_sensor_msgs                           : latest=0.46.4, local=0.46.4
test_tf2                                  : latest=N/A, local=0.46.4
tf2_kdl                                   : latest=0.46.4, local=0.46.4
dummy_robot_bringup                       : latest=0.38.0, local=0.38.0
rviz2                                     : latest=16.0.4, local=16.0.4
rviz_default_plugins                      : latest=16.0.4, local=16.0.4
interactive_markers                       : latest=2.9.2, local=2.9.2
tf2_geometry_msgs                         : latest=0.46.4, local=0.46.4
examples_tf2_py                           : latest=0.46.4, local=0.46.4
tf2_ros_py                                : latest=0.46.4, local=0.46.4
tf2_eigen                                 : latest=0.46.4, local=0.46.4
tf2_bullet                                : latest=0.46.4, local=0.46.4
rviz_visual_testing_framework             : latest=16.0.4, local=16.0.4
rviz_common                               : latest=16.0.4, local=16.0.4
robot_state_publisher                     : latest=3.6.2, local=3.6.2
tf2_ros                                   : latest=0.46.4, local=0.46.4
tf2_py                                    : latest=0.46.4, local=0.46.4
test_tracetools                           : latest=N/A, local=9.0.0
test_rosidl_buffer                        : latest=N/A, local=0.25.3
sros2_cmake                               : latest=0.17.0, local=0.17.0
ros2cli_common_extensions                 : latest=0.6.1, local=0.6.1
sros2                                     : latest=0.17.0, local=0.17.0
rqt_topic                                 : latest=3.0.3, local=3.0.3
rqt_srv                                   : latest=2.0.0, local=2.0.0
rqt_shell                                 : latest=2.0.2, local=2.0.2
rqt_service_caller                        : latest=2.0.2, local=2.0.2
rqt_reconfigure                           : latest=2.0.3, local=2.0.3
rqt_py_console                            : latest=2.0.1, local=2.0.1
rqt_publisher                             : latest=2.0.2, local=2.0.2
rqt_plot                                  : latest=2.0.2, local=2.0.2
rqt_action                                : latest=3.0.0, local=3.0.0
rqt_msg                                   : latest=2.0.3, local=2.0.3
rqt_console                               : latest=3.0.2, local=3.0.2
rqt                                       : latest=2.0.4, local=2.0.4
rqt_py_common                             : latest=2.0.4, local=2.0.4
rqt_graph                                 : latest=2.0.3, local=2.0.3
rqt_bag                                   : latest=2.3.5, local=2.3.5
rqt_gui_py                                : latest=2.0.4, local=2.0.4
rqt_gui_cpp                               : latest=2.0.4, local=2.0.4
rqt_gui                                   : latest=2.0.4, local=2.0.4
rosbag2_performance_benchmarking          : latest=0.35.0, local=0.35.0
rosbag2_examples_py                       : latest=0.35.0, local=0.35.0
rosbag2_py                                : latest=0.35.0, local=0.35.0
rosbag2_examples_cpp                      : latest=0.35.0, local=0.35.0
rosbag2_transport                         : latest=0.35.0, local=0.35.0
rosbag2_test_common                       : latest=0.35.0, local=0.35.0
rosbag2_storage_sqlite3                   : latest=0.35.0, local=0.35.0
rosbag2_compression                       : latest=0.35.0, local=0.35.0
rosbag2_cpp                               : latest=0.35.0, local=0.35.0
rosbag2_storage                           : latest=0.35.0, local=0.35.0
ros_testing                               : latest=0.10.0, local=0.10.0
ros2trace                                 : latest=9.0.0, local=9.0.0
ros2topic                                 : latest=0.42.0, local=0.42.0
ros2test                                  : latest=0.10.0, local=0.10.0
ros2component                             : latest=0.42.0, local=0.42.0
ros2param                                 : latest=0.42.0, local=0.42.0
ros2lifecycle                             : latest=0.42.0, local=0.42.0
ros2service                               : latest=0.42.0, local=0.42.0
ros2run                                   : latest=0.42.0, local=0.42.0
ros2plugin                                : latest=6.0.2, local=6.0.2
ros2launch                                : latest=0.30.2, local=0.30.2
ros2pkg                                   : latest=0.42.0, local=0.42.0
ros2log                                   : latest=0.42.0, local=0.42.0
ros2node                                  : latest=0.42.0, local=0.42.0
ros2multicast                             : latest=0.42.0, local=0.42.0
ros2lifecycle_test_fixtures               : latest=0.42.0, local=0.42.0
ros2interface                             : latest=0.42.0, local=0.42.0
ros2doctor                                : latest=0.42.0, local=0.42.0
ros2action                                : latest=0.42.0, local=0.42.0
ros2cli                                   : latest=0.42.0, local=0.42.0
resource_retriever_service_plugin         : latest=1.0.3, local=1.0.3
resource_retriever_service                : latest=1.0.3, local=1.0.3
quality_of_service_demo_py                : latest=0.38.0, local=0.38.0
quality_of_service_demo_cpp               : latest=0.38.0, local=0.38.0
point_cloud_transport_py                  : latest=6.0.4, local=6.0.4
point_cloud_transport                     : latest=6.0.4, local=6.0.4
image_transport_py                        : latest=7.0.4, local=7.0.4
image_common                              : latest=7.0.4, local=7.0.4
image_transport                           : latest=7.0.4, local=7.0.4
message_filters                           : latest=8.0.4, local=8.0.4
lifecycle_py                              : latest=0.38.0, local=0.38.0
launch_testing_ros                        : latest=0.30.2, local=0.30.2
demo_nodes_cpp                            : latest=0.38.0, local=0.38.0
composition                               : latest=0.38.0, local=0.38.0
launch_ros                                : latest=0.30.2, local=0.30.2
laser_geometry                            : latest=3.0.1, local=3.0.1
examples_rclpy_pointcloud_publisher       : latest=0.22.0, local=0.22.0
examples_rclpy_minimal_subscriber         : latest=0.22.0, local=0.22.0
examples_rclpy_minimal_service            : latest=0.22.0, local=0.22.0
examples_rclpy_minimal_publisher          : latest=0.22.0, local=0.22.0
examples_rclpy_minimal_client             : latest=0.22.0, local=0.22.0
examples_rclpy_minimal_action_server      : latest=0.22.0, local=0.22.0
examples_rclpy_minimal_action_client      : latest=0.22.0, local=0.22.0
examples_rclpy_guard_conditions           : latest=0.22.0, local=0.22.0
examples_rclpy_executors                  : latest=0.22.0, local=0.22.0
demo_nodes_py                             : latest=0.38.0, local=0.38.0
camera_info_manager_py                    : latest=7.0.4, local=7.0.4
action_tutorials_py                       : latest=0.38.0, local=0.38.0
rclpy                                     : latest=11.0.3, local=11.0.3
lifecycle                                 : latest=0.38.0, local=0.38.0
camera_info_manager                       : latest=7.0.4, local=7.0.4
rclcpp_lifecycle                          : latest=33.1.0, local=33.1.0
logging_demo                              : latest=0.38.0, local=0.38.0
image_tools                               : latest=0.38.0, local=0.38.0
examples_rclcpp_wait_set                  : latest=0.22.0, local=0.22.0
examples_rclcpp_minimal_subscriber        : latest=0.22.0, local=0.22.0
examples_rclcpp_minimal_composition       : latest=0.22.0, local=0.22.0
demo_nodes_cpp_native                     : latest=0.38.0, local=0.38.0
action_tutorials_cpp                      : latest=0.38.0, local=0.38.0
rclcpp_components                         : latest=33.1.0, local=33.1.0
examples_rclcpp_minimal_action_server     : latest=0.22.0, local=0.22.0
examples_rclcpp_minimal_action_client     : latest=0.22.0, local=0.22.0
rclcpp_action                             : latest=33.1.0, local=33.1.0
intra_process_demo                        : latest=0.38.0, local=0.38.0
examples_rclcpp_multithreaded_executor    : latest=0.22.0, local=0.22.0
examples_rclcpp_minimal_timer             : latest=0.22.0, local=0.22.0
examples_rclcpp_minimal_service           : latest=0.22.0, local=0.22.0
examples_rclcpp_minimal_publisher         : latest=0.22.0, local=0.22.0
examples_rclcpp_minimal_client            : latest=0.22.0, local=0.22.0
examples_rclcpp_cbg_executor              : latest=0.22.0, local=0.22.0
examples_rclcpp_async_client              : latest=0.22.0, local=0.22.0
dummy_sensors                             : latest=0.38.0, local=0.38.0
dummy_map_server                          : latest=0.38.0, local=0.38.0
camera_calibration_parsers                : latest=7.0.4, local=7.0.4
rclcpp                                    : latest=33.1.0, local=33.1.0
rcl_lifecycle                             : latest=10.5.2, local=10.5.2
rcl_action                                : latest=10.5.2, local=10.5.2
rcl                                       : latest=10.5.2, local=10.5.2
rmw_implementation                        : latest=3.2.1, local=3.2.1
rmw_zenoh_cpp                             : latest=0.14.0, local=0.14.0
zenoh_cpp_vendor                          : latest=0.14.0, local=0.14.0
yaml_cpp_vendor                           : latest=9.3.0, local=9.3.0
common_interfaces                         : latest=5.10.2, local=5.10.2
visualization_msgs                        : latest=5.10.2, local=5.10.2
kdl_parser                                : latest=3.1.0, local=3.1.0
urdf                                      : latest=2.14.1, local=2.14.1
urdf_parser_plugin                        : latest=2.14.1, local=2.14.1
turtlesim_msgs                            : latest=1.11.3, local=1.11.3
trajectory_msgs                           : latest=5.10.2, local=5.10.2
tf2_msgs                                  : latest=0.46.4, local=0.46.4
tf2_eigen_kdl                             : latest=0.46.4, local=0.46.4
tf2                                       : latest=0.46.4, local=0.46.4
test_msgs                                 : latest=2.5.1, local=2.5.1
test_communication                        : latest=N/A, local=0.25.3
stereo_msgs                               : latest=5.10.2, local=5.10.2
std_srvs                                  : latest=5.10.2, local=5.10.2
shape_msgs                                : latest=5.10.2, local=5.10.2
sensor_msgs_py                            : latest=5.10.2, local=5.10.2
map_msgs                                  : latest=2.6.1, local=2.6.1
sensor_msgs                               : latest=5.10.2, local=5.10.2
nav_msgs                                  : latest=5.10.2, local=5.10.2
diagnostic_msgs                           : latest=5.10.2, local=5.10.2
geometry_msgs                             : latest=5.10.2, local=5.10.2
std_msgs                                  : latest=5.10.2, local=5.10.2
statistics_msgs                           : latest=2.5.1, local=2.5.1
rosgraph_msgs                             : latest=2.5.1, local=2.5.1
rosbag2_performance_benchmarking_msgs     : latest=0.35.0, local=0.35.0
rosbag2_interfaces                        : latest=0.35.0, local=0.35.0
ros2cli_test_interfaces                   : latest=0.42.0, local=0.42.0
rmw_fastrtps_cpp                          : latest=9.6.0, local=9.6.0
rmw_cyclonedds_cpp                        : latest=4.2.1, local=4.2.1
rmw_connextddsmicro                       : latest=N/A, local=1.3.0
rmw_connextdds_common                     : latest=1.3.0, local=1.3.0
rmw_connextdds                            : latest=1.3.0, local=1.3.0
rmw_dds_common                            : latest=6.1.2, local=6.1.2
resource_retriever_interfaces             : latest=1.0.3, local=1.0.3
composition_interfaces                    : latest=2.5.1, local=2.5.1
rcl_interfaces                            : latest=2.5.1, local=2.5.1
pendulum_msgs                             : latest=0.38.0, local=0.38.0
lifecycle_msgs                            : latest=2.5.1, local=2.5.1
example_interfaces                        : latest=0.15.0, local=0.15.0
rosidl_default_runtime                    : latest=1.9.0, local=1.9.0
rosidl_default_generators                 : latest=1.9.0, local=1.9.0
action_msgs                               : latest=2.5.1, local=2.5.1
unique_identifier_msgs                    : latest=2.9.0, local=2.9.0
type_description_interfaces               : latest=2.5.1, local=2.5.1
service_msgs                              : latest=2.5.1, local=2.5.1
builtin_interfaces                        : latest=2.5.1, local=2.5.1
rosidl_core_runtime                       : latest=0.5.0, local=0.5.0
rosidl_core_generators                    : latest=0.5.0, local=0.5.0
rosidl_generator_py                       : latest=0.28.0, local=0.28.0
ament_lint_common                         : latest=0.21.3, local=0.21.3
ament_cmake_uncrustify                    : latest=0.21.3, local=0.21.3
ament_uncrustify                          : latest=0.21.3, local=0.21.3
uncrustify_vendor                         : latest=3.3.0, local=3.3.0
tracetools_trace                          : latest=9.0.0, local=9.0.0
tracetools_read                           : latest=9.0.0, local=9.0.0
tracetools                                : latest=9.0.0, local=9.0.0
tlsf                                      : latest=0.12.1, local=0.12.1
test_tracetools_launch                    : latest=N/A, local=9.0.0
test_security                             : latest=N/A, local=0.25.3
test_ros2trace                            : latest=N/A, local=9.0.0
test_rmw_zenoh_cpp                        : latest=N/A, local=0.14.0
test_rmw_implementation                   : latest=N/A, local=3.2.1
test_rclcpp                               : latest=N/A, local=0.25.3
test_quality_of_service                   : latest=N/A, local=0.25.3
test_launch_testing                       : latest=N/A, local=3.10.2
test_launch_ros                           : latest=N/A, local=0.30.2
test_interface_files                      : latest=0.15.0, local=0.15.0
test_cli                                  : latest=N/A, local=0.25.3
qt_gui_core                               : latest=3.0.3, local=3.0.3
qt_gui_cpp                                : latest=3.0.3, local=3.0.3
qt_gui_app                                : latest=3.0.3, local=3.0.3
qt_gui                                    : latest=3.0.3, local=3.0.3
tango_icons_vendor                        : latest=0.6.0, local=0.6.0
rviz_rendering_tests                      : latest=16.0.4, local=16.0.4
rviz_rendering                            : latest=16.0.4, local=16.0.4
rviz_ogre_vendor                          : latest=16.0.4, local=16.0.4
rttest                                    : latest=1.0.1, local=1.0.1
rti_connext_dds_cmake_module              : latest=1.3.0, local=1.3.0
ament_cmake_ros                           : latest=0.16.0, local=0.16.0
rmw_test_fixture_implementation           : latest=0.16.0, local=0.16.0
lttngpy                                   : latest=9.0.0, local=9.0.0
rpyutils                                  : latest=0.8.0, local=0.8.0
rosidl_typesupport_tests                  : latest=N/A, local=3.5.0
rosidl_typesupport_introspection_tests    : latest=N/A, local=5.3.1
rosidl_typesupport_cpp                    : latest=3.5.0, local=3.5.0
rosidl_typesupport_introspection_cpp      : latest=5.3.1, local=5.3.1
rosidl_generator_rs                       : latest=0.5.0, local=0.5.0
rosidl_typesupport_c                      : latest=3.5.0, local=3.5.0
rosidl_typesupport_introspection_c        : latest=5.3.1, local=5.3.1
rosidl_typesupport_fastrtps_c             : latest=3.10.1, local=3.10.1
rosidl_typesupport_fastrtps_cpp           : latest=3.10.1, local=3.10.1
rosidl_generator_cpp                      : latest=5.3.1, local=5.3.1
rosidl_buffer_backend_registry            : latest=5.3.1, local=5.3.1
rosidl_runtime_cpp                        : latest=5.3.1, local=5.3.1
rosidl_dynamic_typesupport_fastrtps       : latest=0.6.0, local=0.6.0
rosidl_buffer_backend                     : latest=5.3.1, local=5.3.1
rmw_test_fixture                          : latest=0.16.0, local=0.16.0
rmw_security_common                       : latest=7.11.2, local=7.11.2
rcl_yaml_param_parser                     : latest=10.5.2, local=10.5.2
rmw                                       : latest=7.11.2, local=7.11.2
rosidl_dynamic_typesupport                : latest=0.5.0, local=0.5.0
rosidl_runtime_c                          : latest=5.3.1, local=5.3.1
rosidl_generator_c                        : latest=5.3.1, local=5.3.1
rosidl_typesupport_interface              : latest=5.3.1, local=5.3.1
rosidl_runtime_py                         : latest=0.16.0, local=0.16.0
rosidl_generator_dds_idl                  : latest=0.14.0, local=0.14.0
rosidl_cmake                              : latest=5.3.1, local=5.3.1
rosidl_pycommon                           : latest=5.3.1, local=5.3.1
rosidl_generator_type_description         : latest=5.3.1, local=5.3.1
rosidl_parser                             : latest=5.3.1, local=5.3.1
rosidl_generator_tests                    : latest=N/A, local=5.3.1
rosidl_adapter                            : latest=5.3.1, local=5.3.1
rosidl_cli                                : latest=5.3.1, local=5.3.1
rosidl_buffer_py                          : latest=5.3.1, local=5.3.1
rosidl_buffer                             : latest=5.3.1, local=5.3.1
rosbag2_tests                             : latest=0.35.0, local=0.35.0
rosbag2_test_msgdefs                      : latest=0.35.0, local=0.35.0
ros_environment                           : latest=5.0.0, local=5.0.0
rmw_implementation_cmake                  : latest=7.11.2, local=7.11.2
resource_retriever                        : latest=3.10.1, local=3.10.1
rcl_logging_implementation                : latest=3.5.0, local=3.5.0
rcl_logging_spdlog                        : latest=3.5.0, local=3.5.0
pluginlib                                 : latest=6.0.2, local=6.0.2
class_loader                              : latest=3.0.2, local=3.0.2
rcpputils                                 : latest=2.15.2, local=2.15.2
rcl_logging_noop                          : latest=3.5.0, local=3.5.0
rcl_logging_interface                     : latest=3.5.0, local=3.5.0
rcutils                                   : latest=7.2.2, local=7.2.2
qt_gui_py_common                          : latest=3.0.3, local=3.0.3
qt_dotgraph                               : latest=3.0.3, local=3.0.3
python_qt_binding                         : latest=2.6.2, local=2.6.3
performance_test_fixture                  : latest=0.5.1, local=0.5.1
mimick_vendor                             : latest=0.10.0, local=0.10.0
lz4_cmake_module                          : latest=0.35.0, local=0.35.0
libyaml_vendor                            : latest=1.9.0, local=1.9.0
launch_testing_ament_cmake                : latest=3.10.2, local=3.10.2
launch_pytest                             : latest=3.10.2, local=3.10.2
launch_testing                            : latest=3.10.2, local=3.10.2
launch_yaml                               : latest=3.10.2, local=3.10.2
launch_xml                                : latest=3.10.2, local=3.10.2
launch                                    : latest=3.10.2, local=3.10.2
keyboard_handler                          : latest=0.6.0, local=0.6.0
gz_math_vendor                            : latest=0.5.3, local=0.5.3
gz_utils_vendor                           : latest=0.5.2, local=0.5.2
gz_cmake_vendor                           : latest=0.5.3, local=0.5.3
ament_cmake_google_benchmark              : latest=2.9.2, local=2.9.2
eigen3_cmake_module                       : latest=0.6.0, local=0.6.0
domain_coordinator                        : latest=0.16.0, local=0.16.0
console_bridge_vendor                     : latest=1.10.0, local=1.10.0
ament_cmake_xmllint                       : latest=0.21.3, local=0.21.3
ament_xmllint                             : latest=0.21.3, local=0.21.3
ament_cmake_pyflakes                      : latest=0.21.3, local=0.21.3
ament_pyflakes                            : latest=0.21.3, local=0.21.3
ament_cmake_pycodestyle                   : latest=0.21.3, local=0.21.3
ament_pycodestyle                         : latest=0.21.3, local=0.21.3
ament_cmake_pep257                        : latest=0.21.3, local=0.21.3
ament_pep257                              : latest=0.21.3, local=0.21.3
ament_cmake_pclint                        : latest=0.21.3, local=0.21.3
ament_pclint                              : latest=0.21.3, local=0.21.3
ament_lint_auto                           : latest=0.21.3, local=0.21.3
ament_cmake_auto                          : latest=2.9.2, local=2.9.2
ament_cmake                               : latest=2.9.2, local=2.9.2
ament_cmake_version                       : latest=2.9.2, local=2.9.2
ament_cmake_vendor_package                : latest=2.9.2, local=2.9.2
ament_cmake_pytest                        : latest=2.9.2, local=2.9.2
ament_cmake_mypy                          : latest=0.21.3, local=0.21.3
ament_cmake_lint_cmake                    : latest=0.21.3, local=0.21.3
ament_cmake_gmock                         : latest=2.9.2, local=2.9.2
ament_cmake_gtest                         : latest=2.9.2, local=2.9.2
ament_cmake_flake8                        : latest=0.21.3, local=0.21.3
ament_cmake_cpplint                       : latest=0.21.3, local=0.21.3
ament_cmake_cppcheck                      : latest=0.21.3, local=0.21.3
ament_cmake_copyright                     : latest=0.21.3, local=0.21.3
ament_cmake_clang_tidy                    : latest=0.21.3, local=0.21.3
ament_cmake_clang_format                  : latest=0.21.3, local=0.21.3
ament_cmake_test                          : latest=2.9.2, local=2.9.2
ament_cmake_target_dependencies           : latest=2.9.2, local=2.9.2
ament_cmake_ros_core                      : latest=0.16.0, local=0.16.0
ament_cmake_python_test                   : latest=N/A, local=2.9.2
ament_cmake_python                        : latest=2.9.2, local=2.9.2
ament_cmake_export_dependencies           : latest=2.9.2, local=2.9.2
ament_cmake_libraries                     : latest=2.9.2, local=2.9.2
ament_cmake_include_directories           : latest=2.9.2, local=2.9.2
ament_cmake_gen_version_h                 : latest=2.9.2, local=2.9.2
ament_cmake_export_targets                : latest=2.9.2, local=2.9.2
ament_cmake_export_link_flags             : latest=2.9.2, local=2.9.2
ament_cmake_export_libraries              : latest=2.9.2, local=2.9.2
ament_cmake_export_include_directories    : latest=2.9.2, local=2.9.2
ament_cmake_export_definitions            : latest=2.9.2, local=2.9.2
ament_cmake_core                          : latest=2.9.2, local=2.9.2
ament_package                             : latest=0.19.1, local=0.19.1
ament_mypy                                : latest=0.21.3, local=0.21.3
ament_lint_cmake                          : latest=0.21.3, local=0.21.3
ament_flake8                              : latest=0.21.3, local=0.21.3
ament_copyright                           : latest=0.21.3, local=0.21.3
ament_clang_tidy                          : latest=0.21.3, local=0.21.3
ament_clang_format                        : latest=0.21.3, local=0.21.3
ament_lint                                : latest=0.21.3, local=0.21.3
ament_index_python                        : latest=1.14.2, local=1.14.2
ament_index_cpp                           : latest=1.14.2, local=1.14.2
ament_cpplint                             : latest=0.21.3, local=0.21.3
ament_cppcheck                            : latest=0.21.3, local=0.21.3

   PLATFORM INFORMATION
system           : Linux
platform info    : Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.43
release          : 6.18.33.2-microsoft-standard-WSL2
processor        :

   QOS COMPATIBILITY LIST
compatibility status    : No publisher/subscriber pairs found

   RMW MIDDLEWARE
middleware name    : rmw_fastrtps_cpp

   ROS 2 INFORMATION
distribution name      : rolling
distribution type      : ros2
distribution status    : rolling
release platforms      : {'debian': ['trixie'], 'fedora': ['44'], 'rhel': ['10'], 'ubuntu': ['resolute']}

   SERVICE LIST
service          : none
service count    : 0
client count     : 0

   TOPIC LIST
topic               : none
publisher count     : 0
subscriber count    : 0

================================================================================
                                !!! WARNING !!!
================================================================================
The report includes all ROS 2 endpoint information and system platform information.
Please review the report before sharing, as it may contain sensitive or private data.
================================================================================

### Steps to reproduce issue
  1. Build ROS 2 Rolling from source and source it: source ~/ros2_rolling/install/local_setup.bash
  2. Run any of these:
    ros2 interface show tf2_msgs/msg/TFMessage | head -1
    ros2 interface list | head -1
    ros2 pkg executables | head -1
    
  3. Check the exit code:
    ros2 interface show tf2_msgs/msg/TFMessage | head -1; echo "exit code: ${PIPESTATUS[0]}"
    
Expected behavior

The command exits quietly after head closes the pipe, like standard tools do (e.g. seq 100000 | head -1). No traceback on stderr.

Actual behavior

The first line is printed, then a BrokenPipeError: [Errno 32] Broken pipe traceback is printed to stderr, followed by "Exception ignored while flushing sys.stdout". The exit code is 120.

Traceback (ros2 pkg executables | head -1)
action_tutorials_cpp fibonacci_action_client
Traceback (most recent call last):
  File "/home/tata_centre/ros2_rolling/install/ros2cli/bin/ros2", line 33, in <module>
    sys.exit(load_entry_point('ros2cli', 'console_scripts', 'ros2')())
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/tata_centre/ros2_rolling/build/ros2cli/ros2cli/cli.py", line 91, in main
    rc = extension.main(parser=parser, args=args)
  File "/home/tata_centre/ros2_rolling/build/ros2pkg/ros2pkg/command/pkg.py", line 37, in main
    return extension.main(args=args)
           ~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/tata_centre/ros2_rolling/build/ros2pkg/ros2pkg/verb/executables.py", line 55, in main
    print(package_name, os.path.basename(path))
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored while flushing sys.stdout:
BrokenPipeError: [Errno 32] Broken pipe
Additional information
  • Affected: interface show, interface list, pkg executables. ros2 pkg list | head -1 did not reproduce for me, probably because its small output (~6 KB) is written before head exits, so it's timing-dependent.
  • Looking at the code, ros2cli/ros2cli/cli.py main() catches KeyboardInterrupt and ExternalShutdownException around extension.main(), but not BrokenPipeError, so every verb is affected.
  • Python's docs describe the standard handling: https://docs.python.org/3/library/signal.html#note-on-sigpipe
  • Would a fix in cli.py main() that handles this once for all verbs be welcome? Happy to open a PR. Open question: which exit code you'd prefer (e.g. 1, or 141 like SIGPIPE).
Dominant language
Python
Stars
274
Forks
246
Avg merge
1d 14h
Merged PRs (30d)
12

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ros2/ros2cli

All issues in ros2/ros2cli

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.