ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to fix colcon build fail?

asked 2019-12-04 09:47:27 -0500

Py gravatar image

Hi all,

I am trying to follow this tutorial https://index.ros.org/doc/ros2/Tutori... for ROS 2.0 Eloquent on Mac OS Catalina. This fails after entering the colcon build --symlink-install command and I get this error message:

user@users-MBP ros2_example_ws % sudo colcon build --symlink-install
Password:
Starting >>> examples_rclcpp_minimal_action_client
Starting >>> examples_rclcpp_minimal_action_server
Starting >>> examples_rclcpp_minimal_client
Starting >>> examples_rclcpp_minimal_composition
--- stderr: examples_rclcpp_minimal_action_server
Traceback (most recent call last):
  File "/Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", line 21, in <module>
    from ament_package.templates import get_environment_hook_template_path
ModuleNotFoundError: No module named 'ament_package'
CMake Error at /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
  execute_process(/usr/local/bin/python3
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
  /Users/user/Desktop/ros2_example_ws/build/examples_rclcpp_minimal_action_server/ament_cmake_package_templates/templates.cmake)
  returned error code 1
Call Stack (most recent call first):
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:38 (include)
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake/cmake/ament_cmakeConfig.cmake:38 (include)
  CMakeLists.txt:13 (find_package)


---
Failed   <<< examples_rclcpp_minimal_action_server  [ Exited with code 1 ]
--- stderr: examples_rclcpp_minimal_action_client
Traceback (most recent call last):
  File "/Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", line 21, in <module>
    from ament_package.templates import get_environment_hook_template_path
ModuleNotFoundError: No module named 'ament_package'
CMake Error at /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
  execute_process(/usr/local/bin/python3
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
  /Users/user/Desktop/ros2_example_ws/build/examples_rclcpp_minimal_action_client/ament_cmake_package_templates/templates.cmake)
  returned error code 1
Call Stack (most recent call first):
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:38 (include)
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake/cmake/ament_cmakeConfig.cmake:38 (include)
  CMakeLists.txt:13 (find_package)


---
Aborted  <<< examples_rclcpp_minimal_action_client
--- stderr: examples_rclcpp_minimal_composition
Traceback (most recent call last):
  File "/Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", line 21, in <module>
    from ament_package.templates import get_environment_hook_template_path
ModuleNotFoundError: No module named 'ament_package'
CMake Error at /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
  execute_process(/usr/local/bin/python3
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
  /Users/user/Desktop/ros2_example_ws/build/examples_rclcpp_minimal_composition/ament_cmake_package_templates/templates.cmake)
  returned error code 1
Call Stack (most recent call first):
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:38 (include)
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake/cmake/ament_cmakeConfig.cmake:38 (include)
  CMakeLists.txt:13 (find_package)


---
Aborted  <<< examples_rclcpp_minimal_composition
--- stderr: examples_rclcpp_minimal_client
Traceback (most recent call last):
  File "/Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", line 21, in <module>
    from ament_package.templates import get_environment_hook_template_path
ModuleNotFoundError: No module named 'ament_package'
CMake Error at /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
  execute_process(/usr/local/bin/python3
  /Users/user/ros2_eloquent/ros2-osx/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py


    /Users/user/Desktop/ros2_example_ws/build/examples_rclcpp_minimal_client/ament_cmake_package_templates/templates.cmake)
      returned error code 1
    Call Stack ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-12-11 03:39:03 -0500

Py gravatar image

After looking at this again I have found that I needed to add source ~/ros2_eloquent/ros2-osx/setup.bash to the .bashrcfile. This was explained in the instruction at https://index.ros.org/doc/ros2/Instal... but I've misunderstood something and thought I needed to use the .zshrc rather than .bashrc on OSX Catalina, which has proved not to be the case.

Thanks for helping to solve this!

edit flag offensive delete link more

Comments

glad you found the correct fix! You should be able to mark your own answer as correct (so that this issue can be considered closed)

marguedas gravatar image marguedas  ( 2019-12-11 11:56:56 -0500 )edit
2

answered 2019-12-04 09:54:16 -0500

marguedas gravatar image

May not qualify as an answer but these errors usually happen when the environment is not set up properly.

Did you follow the previous steps of the tutorial? Especially the "Source an underlay" section, if you install eloquent from binaries it should look similar to https://index.ros.org/doc/ros2/Instal...

Also it is surprising that you have to run colcon with sudo. Does it fail differently if you build without sudo?

edit flag offensive delete link more

Comments

Thanks for the reply! I believe I followed the "Source an underlay" section, but it is possible that I've made a mistake. Here's the contents of my .zshrc file:

export OPENSSL_ROOT_DIR=/usr/local/opt/openssl
export PATH="/usr/local/sbin:$PATH"
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1
source ~/ros2_eloquent/ros2-osx/setup.zsh

Does this look like it's got any obvious errors in it? I run colcon with sudo because it just gives me a permission denied error otherwise. Do you think this gives any clues?

Py gravatar image Py  ( 2019-12-06 05:25:22 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-12-04 09:47:27 -0500

Seen: 5,468 times

Last updated: Dec 11 '19