Could not find a package configuration file provided by “ament_lint_auto”

Jamil 发布于 2024-12-17 30 次阅读


问题背景

ros2使用colcon编译程序时报错

Bash
Starting >>> constants
--- stderr: constants                         
CMake Error at CMakeLists.txt:32 (find_package):
  By not providing "Findament_lint_auto.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "ament_lint_auto", but CMake did not find one.

  Could not find a package configuration file provided by "ament_lint_auto"
  with any of the following names:

    ament_lint_autoConfig.cmake
    ament_lint_auto-config.cmake

  Add the installation prefix of "ament_lint_auto" to CMAKE_PREFIX_PATH or
  set "ament_lint_auto_DIR" to a directory containing one of the above files.
  If "ament_lint_auto" provides a separate development package or SDK, be
  sure it has been installed.


---
Failed   <<< constants [0.30s, exited with code 1]

Summary: 0 packages finished [0.60s]
  1 package failed: constants
  1 package had stderr output: constants
  2 packages not processed

我低头一看这不是没source ros的环境么,于是输入

Bash
source /opt/ros/foxy/setup.zsh

然后还是这个问题,一脸懵逼

解决方法

原来是不知道什么时候auto remove把ament_lint_auto给我卸载掉了(auto remove真心慎用)

检查ament_lint_auto是否正常

Bash
dpkg -l | grep ament-lint-auto

如果没有输出重新安装即可

Bash
sudo apt update
sudo apt install ros-foxy-ament-lint-auto