ament_cmake_core fails to compile

asked 2022-11-08 00:16:43 -0500

tomkimsour gravatar image

I am trying to compile ros_base (galactic) on gentoo with the command emerge ros-galactic/ros_base however the package ament_cmake_core seems to fail. If I run emerge --info '=ros-galactic/ament_cmake_core-1.1.4-r1::ros-overlay' I get the error below.

loading initial cache file /tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/work/ament_cmake_core-1.1.4_build/gentoo_common_config.cmake
-- Found PythonInterp: /tmp/gentoo/usr/bin/python (found suitable version "3.8.15", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /tmp/gentoo/usr/bin/python
-- ament_cmake_core 1.1.4 
Traceback (most recent call last):   
    File "/tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/work/ament_cmake_core-1.1.4/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 ament_cmake_package_templates-extras.cmake:41 (message):   
    execute_process(/tmp/gentoo/usr/bin/python 
    /tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/work/ament_cmake_core-1.1.4/cmake/package_templates/templates_2_cmake.py 
    /tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/work/ament_cmake_core-1.1.4_build/ament_cmake_package_templates/templates.cmake) 
    returned error code 1 
Call Stack (most recent call first):   
    CMakeLists.txt:19 (include)

-- Configuring incomplete, errors occurred!
See also "/tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/work/ament_cmake_core-1.1.4_build/CMakeFiles/CMakeOutput.log".
 * ERROR: ros-galactic/ament_cmake_core-1.1.4-r1::ros-overlay failed (configure phase):
 *   cmake failed
 *
 * Call stack:
 *     ebuild.sh, line  122:  Called src_configure
 *   environment, line 3498:  Called ament-cmake_src_configure
 *   environment, line 1294:  Called cmake-utils_src_configure
 *   environment, line 1691:  Called die
 * The specific snippet of code:
 *       "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";
 *
 * If you need support, post the output of `emerge --info '=ros-galactic/ament_cmake_core-1.1.4-r1::ros-overlay'`,
 * the complete build log and the output of `emerge -pqv '=ros-galactic/ament_cmake_core-1.1.4-r1::ros-overlay'`.
 * The complete build log is located at '/tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/temp/build.log'.
 * The ebuild environment file is located at '/tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/temp/environment'.
 * Working directory: '/tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/work/ament_cmake_core-1.1.4_build'
 * S: '/tmp/gentoo/var/tmp/portage/ros-galactic/ament_cmake_core-1.1.4-r1/work/ament_cmake_core-1.1.4'

As mentioned here it might be related to the PYTHON_PATH environment variable. However, it looks looks like ros python packages are installed under the /opt/ros/galactic/lib/python3.8/site-packages/ which doesn't exist before emerging the package. Where exactly am I supposed to find the ament packages ?

Following are the path of my PYTHON_PATH :

/tmp/gentoo/usr/lib/python38.zip
/tmp/gentoo/usr/lib/python3.8
/tmp/gentoo/usr/lib/python3.8/lib-dynload
/tmp/gentoo/usr/lib/python3.8/site-packages
edit retag flag offensive close merge delete

Comments

ModuleNotFoundError: No module named 'ament_package'

It seems that it is looking for the ament_package which is not installed. Next, on a normal Ubuntu OS, the environment variable PYTHONPATH points to ROS installation directory as shown below:

$ printenv | grep PYTHON
ROS_PYTHON_VERSION=3
PYTHONPATH=/opt/ros/galactic/lib/python3.8/site-packages
ravijoshi gravatar image ravijoshi  ( 2022-11-08 00:25:12 -0500 )edit

I tried doing emerge ros-galactic/ament_package, it compiles without any errors but it is not /tmp/gentoo/usr/lib/python3.8/site-packages/

tomkimsour gravatar image tomkimsour  ( 2022-11-08 00:27:46 -0500 )edit

what you added in your edit is mentioned at the end of the post. Because I am trying to install ROS, this folder doesn't seem to exist yet.

tomkimsour gravatar image tomkimsour  ( 2022-11-08 16:33:34 -0500 )edit

I was able to fix this by cloning the repository ament_package under /tmp/gentoo/usr/lib/python3.8/site-packages/ament_package , install it using pip install -e /tmp/gentoo/usr/lib/python3.8/site-packages/ament_package

It seems to be a working solution but if anyone finds something more generic. Please share it.

tomkimsour gravatar image tomkimsour  ( 2022-11-08 18:09:27 -0500 )edit