ros2 test_error ai_generated true

colcon test: 找不到测试依赖项:'python3-pytest'、'ros_testing'未安装

colcon test: Failed to find test dependencies: 'python3-pytest', 'ros_testing' not installed

ID: ros2/colcon-test-failure-test-dependencies-not-installed

其他格式: JSON · Markdown 中文 · English
88%修复率
85%置信度
1证据数
2024-01-20首次发现

版本兼容性

版本状态引入弃用备注
Humble active
Iron active
Rolling active

根因分析

colcon test需要安装package.xml中指定的测试依赖项(位于<test_depend>下)。缺少系统或ROS包会导致测试执行失败。

English

colcon test requires test dependencies specified in package.xml (under <test_depend>) to be installed in the workspace. Missing system or ROS packages cause test execution to fail.

generic

官方文档

https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Package.html#test-your-package

解决方案

  1. Install test dependencies explicitly: rosdep install --from-paths src --ignore-src -r -y --rosdistro humble --include-test-dependencies. Then run colcon test again.
  2. For missing system packages like python3-pytest, install manually: sudo apt-get install python3-pytest. For ROS packages like ros_testing: sudo apt-get install ros-humble-ros-testing.
  3. If test dependencies are optional, temporarily remove them from package.xml and run colcon test with --packages-skip-build-failed to skip problematic packages.

无效尝试

常见但无效的做法:

  1. 95% 失败

    The error will still occur for the selected package if dependencies are missing. The --packages-select flag doesn't bypass dependency resolution.

  2. 85% 失败

    This command by default skips test dependencies unless --rosdistro and --include-test-dependencies are specified.