Failed to create symbolic link - Services Quiz

Hi

I was done with the services_quiz and when I send my solution there’s and error to building

   colcon build --packages-select services_quiz_srv services_quiz

shell response:

user:~/ros2_ws$ colcon build --packages-select services_quiz_srv services_quiz
Starting >>> services_quiz_srv
--- stderr: services_quiz_srv
failed to create symbolic link '/home/user/ros2_ws/build/services_quiz_srv/ament_cmake_python/services_quiz_srv/services_quiz_srv' because existing path cannot be removed: Is a directory
gmake[2]: *** [CMakeFiles/ament_cmake_python_symlink_services_quiz_srv.dir/build.make:70: CMakeFiles/ament_cmake_python_symlink_services_quiz_srv] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:421: CMakeFiles/ament_cmake_python_symlink_services_quiz_srv.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< services_quiz_srv [2.39s, exited with code 2]

Summary: 0 packages finished [2.61s]
  1 package failed: services_quiz_srv
  1 package had stderr output: services_quiz_srv
  1 package not processed

Then the process automatic qualify stops and no check the other things.

But, when I trying to launch my server and client by myself, both of them work and do the task.
I don’t understand the error.

Hi @Voltedge ,

Did you create services_quiz_srv package with build-type as ament_cmake or ament_cmake_python?
Because from the error code above, I infer that you have used the wrong build type.

You must build services_quiz_srv with build-type ament_cmake.

To see which build-type your package uses, check your <build_type> tag in your package.xml.

If you have used ament_cmake_python then re-create the package from scratch using ament_cmake.

Regards,
Girish

Hi @girishkumar.kannan

both of them are ament_cmake

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>services_quiz_srv</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="user@todo.todo">user</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>rclcpp</depend>
  <depend>std_msgs</depend>


  
  <build_depend>rosidl_default_generators</build_depend>
  <exec_depend>rosidl_default_runtime</exec_depend>
  <member_of_group>rosidl_interface_packages</member_of_group>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

Hi @Voltedge ,

Delete build, install and log folders from ros2_ws and try to build all the packages again.
Simply do colcon build after deleting the above 3 folders.

That should most likely fix your problem. Let me know if that does not fix!

Regards,
Girish

Hi @girishkumar.kannan

I delete those files and then compile with: colcon build

user:~/ros2_ws$ colcon build
Starting >>> services_quiz_srv
[0.731s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/topics_quiz' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.731s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/services_quiz' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.731s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/services_quiz_srv' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.731s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/server_pkg' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/my_package' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/exercise42_pkg' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/custom_interfaces' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/client_pkg' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/topics_quiz' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/topic_subscriber_pkg' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/topic_publisher_pkg' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/services_quiz' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/services_quiz_srv' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/server_pkg' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/my_package' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/exercise42_pkg' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/custom_interfaces' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.732s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/client_pkg' in the environment variable CMAKE_PREFIX_PATH doesn't exist
Starting >>> client_pkg
Starting >>> exercise42_pkg
Starting >>> server_pkg
Starting >>> topics_quiz
[Processing: client_pkg, exercise42_pkg, server_pkg, services_quiz_srv, topics_quiz]
Finished <<< exercise42_pkg [32.5s]
Finished <<< services_quiz_srv [39.6s]
Starting >>> services_quiz
Finished <<< server_pkg [39.6s]
Finished <<< client_pkg [40.2s]
Finished <<< topics_quiz [42.7s]
Finished <<< services_quiz [15.9s]

Summary: 6 packages finished [55.7s]

Second compile with :

       colcon build --packages-select services_quiz_srv services_quiz


  user:~/ros2_ws$ colcon build --packages-select services_quiz_srv services_quiz
  Starting >>> services_quiz_srv
  [0.659s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/my_package' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.659s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/custom_interfaces' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.659s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/topic_subscriber_pkg' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.660s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/topic_publisher_pkg' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.660s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/my_package' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.660s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/custom_interfaces' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  Finished <<< services_quiz_srv [1.07s]
  Starting >>> services_quiz
  Finished <<< services_quiz [0.30s]
  
  Summary: 2 packages finished [1.56s]

I guess that this errors will make me fail the services_quiz again ?

Hi @Voltedge ,

Please just take a moment to read the output. Those are not errors. Just warnings.
All your packages are successfully compiled.

Just execute your package. They should run fine!

Execute them manually (on the terminal by yourself) first. Then use the gradebot.

Regards,
Girish

Hi @girishkumar.kannan

I did a full build, then one on the 2 packages (services_quiz, services_quiz_srv) and everything works. But then I use Gradebot and I get the same error again.

I compile again and now I get the same error from the beginning…

    user:~/ros2_ws$ colcon build
    Starting >>> services_quiz_srv
    Starting >>> client_pkg
    Starting >>> exercise42_pkg
    Starting >>> server_pkg
    Starting >>> topics_quiz
    Finished <<< exercise42_pkg [3.68s]
    Finished <<< client_pkg [3.71s]
    Finished <<< topics_quiz [3.72s]
    Finished <<< services_quiz_srv [4.32s]
    Starting >>> services_quiz
    Finished <<< server_pkg [4.30s]
    Finished <<< services_quiz [0.30s]
    
    Summary: 6 packages finished [5.80s]
    user:~/ros2_ws$ ros2 launch services_quiz services_quiz_server.launch.py
    [INFO] [launch]: All log files can be found below /home/user/.ros/log/2023-01-08-22-29-24-569262-4_xterm-2048
    [INFO] [launch]: Default logging verbosity is set to INFO
    [INFO] [srv_cpp-1]: process started with pid [2049]
    ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
    [srv_cpp-1] [INFO] [1673216992.292107343] [rclcpp]: signal_handler(signum=2)
    [INFO] [srv_cpp-1]: process has finished cleanly [pid 2049]
    user:~/ros2_ws$ colcon build --packages-select services_quiz services_quiz_srv
    Starting >>> services_quiz_srv
    Finished <<< services_quiz_srv [0.99s]
    Starting >>> services_quiz
    Finished <<< services_quiz [0.25s]
    
    Summary: 2 packages finished [1.41s]

Here I send to the Gradebot and I fail again. So, when I compile again…

    user:~/ros2_ws$ colcon build --packages-select services_quiz services_quiz_srv
    Starting >>> services_quiz_srv
    --- stderr: services_quiz_srv
    failed to create symbolic link '/home/user/ros2_ws/build/services_quiz_srv/ament_cmake_python/services_quiz_srv/services_quiz_srv' because existing path cannot be removed: Is a directory
    gmake[2]: *** [CMakeFiles/ament_cmake_python_symlink_services_quiz_srv.dir/build.make:70: CMakeFiles/ament_cmake_python_symlink_services_quiz_srv] Error 1
    gmake[1]: *** [CMakeFiles/Makefile2:421: CMakeFiles/ament_cmake_python_symlink_services_quiz_srv.dir/all] Error 2
    gmake[1]: *** Waiting for unfinished jobs....
    gmake: *** [Makefile:146: all] Error 2
    ---
    Failed   <<< services_quiz_srv [0.31s, exited with code 2]
    
    Summary: 0 packages finished [0.52s]
      1 package failed: services_quiz_srv
      1 package had stderr output: services_quiz_srv
      1 package not processed
    user:~/ros2_ws$

What I am wrong?

Good evening,
To solve the issue, delete manually the folder ros2_ws/build/services_quiz_srv/ament_cmake_python;

then, do a bunch of compilation attempts on your own before you try to resubmit;

I have no clue what’s happening, but I suspect that when we compile an interface package for the first time, that directory gets odd permissions and the compiler can’t mess with it anymore;

Hope this helps

Kind regards

Francesco