Unable to run colcon build

colcon build
Starting >>> custom_interfaces
Starting >>> my_package
Starting >>> topic_subscriber_pkg
Starting >>> topics_quiz
— stderr: custom_interfaces
failed to create symbolic link ‘/home/user/ros2_ws/build/custom_interfaces/ament_cmake_python/custom_interfaces/custom_interfaces’ because existing path cannot be removed: Is a
directory
gmake[2]: *** [CMakeFiles/ament_cmake_python_symlink_custom_interfaces.dir/build.make:70: CMakeFiles/ament_cmake_python_symlink_custom_interfaces] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:421: CMakeFiles/ament_cmake_python_symlink_custom_interfaces.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs…
gmake: *** [Makefile:146: all] Error 2

Failed <<< custom_interfaces [0.65s, exited with code 2]
Aborted <<< my_package [0.67s]
Aborted <<< topics_quiz [0.64s]
Aborted <<< topic_subscriber_pkg [0.66s]

Summary: 0 packages finished [0.92s]
1 package failed: custom_interfaces
3 packages aborted: my_package topic_subscriber_pkg topics_quiz
4 packages had stderr output: custom_interfaces my_package topic_subscriber_pkg topics_quiz
1 package not processed

Hi @ankur.tiwari0608 ,

Welcome to this Community!

Try to delete the build and devel directories inside catkin_ws and rebuild.

cd ~/catkin_ws
sudo rm -rf ./build ./devel
catkin_make && source devel/setup.bash

The above steps should fix this problem. Let me know if you still have issues.

Regards,
Girish

Hi @ankur.tiwari0608 ,

The error you are encountering suggests that the file your building already is a directory (hence “failed to create symbolic link”). I recommend cleaning your build file using the command
rm -r /home/user/ros2_ws/build/* or
colcon build --symlink-install --cmake-clean-cache
then rebuild using colcon build and don’t forget to source your workspace.

Hope this helps.

Kind Regards,
Sarah