Galactic: 'No rule to make target' for custom messages
This is for Galactic / Ubuntu 20.04.
I'm new to ROS2 and am getting a consistent 'No rule to make target' error when trying to build packages that produce interfaces via the rosidl_generate_interfaces
command. Here is an example for the turtlesim
package.
--- stderr: turtlesim
make[1]: *** No rule to make target 'turtlesim__py/CMakeFiles/turtlesim__py.dir/all', needed by 'CMakeFiles/turtlesim__python.dir/all'. Stop.
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:146: all] Error 2
---
Failed <<< turtlesim [5.25s, exited with code 2]
I've dug into the relevant build files to investigate. In turtlesim/CMakeFiles//Makefile I see line 429 where the error is thrown:
CMakeFiles/turtlesim__python.dir/all: turtlesim__py/CMakeFiles/turtlesim__py.dir/all
The error is that the dependency turtlesim__py/CMakeFiles/turtlesim__py.dir/all
does not exist. However, I see farther down on line 656 that this target is created:
/home/blake/ros2/build/turtlesim/turtlesim__py/CMakeFiles/turtlesim__py.dir/all
The difference being that the target uses an absolute path when declared, but a path relative to the makefile when called as a dependency. The relative path is not recognized as equivalent to the absolute path.
Can anyone explain the cause of this issue? I expect it must be some kind of environment configuration problem, but my env variables all appear correct per the ROS2 tutorials.
A possible clue. If I run colcon within the package directory instead of the workspace root, it builds successfully. When I inspect these same lines in the generated makefile, I see that relative paths are used throughout for consistency. The question, then, is why colcon generates targets with absolute paths when it runs in the workspace root.
I see @sardanian had a similar issue recently, but their question was not resolved: https://answers.ros.org/question/4029...
I have the exact same issue on Humble / Ubuntu 22.04 with the tutorial_interfaces. Thought it was related to Python 3.10, so I switch to Foxy / Ubuntu 20.04 : same issue... So rosidl_generator is the issue ?!
Seems to be. I can suppress the error by commenting out that part of the CMakelists.