ROS2 basics in 5 days

I stucked on exercise 3.2.1. Have this error:
user:~/ros2_ws$ colcon build --packages-select publisher_pkg
[1.006s] ERROR:colcon:colcon build: Duplicate package names not supported:

And actually I see another folder with the same name. But that’s what steps in exercise are telling me to do. How can I fix it?

Hi @stanislav.sakal ,

Welcome to this Community!

As the colcon build error output says, you have more than one ROS2 package with the same name publisher_pkg.

The package contents looks fine to me from what I see from your image on the IDE’s left panel.
But you could be having a duplicate somewhere else. As the colcon build error reports, I understand that you have one package in ~/ros2_ws folder and the other one in the ~/ros2_ws/src folder.

To get rid of this error, you need to remove the package in the ~/ros2_ws folder and retain the package inside the ~/ros2_ws/src folder - because as a convention, we do not place packages directly inside the ~/ros2_ws folder (and only inside the src folder).

Before you delete the package, make sure that the contents are the same in both the packages (if the purpose for both the packages are the same).

Once you have removed the duplicate package (the one in ~/ros2_ws folder), make sure to recompile from scratch.

Steps to recompile from scratch:

cd ~/ros2_ws
rm -rf ./build ./install ./log
colcon build
source install/setup.bash

Doing these steps will fix your issue.

Let me know if your problem is solved after following these steps.

Regards,
Girish

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.