0
$\begingroup$

Rosanswers logo

I am trying to compile ROS2 from source on Docker (for development purposes) but am running into several issues while doing so. Any pointers at what might be wrong here?

  • Operating System:
    • Ubuntu22.04 (Jammy)
  • Installation type:
    • source
  • Version or commit hash:

Steps to reproduce issue

Essentially follow the instructions at Linux Development Setup for Rolling. I created a Dockerfile that executes these in this gist

Expected behavior

Build completes and the example can be run inside the container

Actual behavior

colcon build --symlink-install fails at FortranCInterface which seems to be a CMake dependency.

Before that, I get several variations of this error which seems unrelated:


Traceback (most recent call last):
   File "", line 1, in 
   File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 10, in 
     import distutils.core
   File "/usr/lib/python3/dist-packages/numpy/distutils/__init__.py", line 24, in 
     from . import ccompiler
   File "/usr/lib/python3/dist-packages/numpy/distutils/ccompiler.py", line 9, in 
     from distutils.ccompiler import (
 ImportError: cannot import name 'compiler_class' from partially initialized module 'distutils.ccompiler' (most likely due to a circular import) (/usr/lib/python3/dist-packages/numpy/distutils/ccompiler.py)
 [1.143s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'python_setup_py' in 'lib/python3/dist-packages/numpy': Command '['/usr/bin/python3', '-c', "import sys;from setuptools.extern.packaging.specifiers import SpecifierSet;from distutils.core import run_setup;dist = run_setup(    'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = {    key: value for key, value in dist.__dict__.items()     if (        not key.startswith('_') and         not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data['metadata'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))"]' returned non-zero exit status 1.
 Traceback (most recent call last):
   File "/usr/lib/python3/dist-packages/colcon_core/package_identification/__init__.py", line 142, in _identify
     retval = extension.identify(_reused_descriptor_instance)
   File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 48, in identify
     config = get_setup_information(setup_py)
   File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 241, in get_setup_information
     _setup_information_cache[hashable_env] = _get_setup_information(
   File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 281, in _get_setup_information
     result = subprocess.run(
   File "/usr/lib/python3.10/subprocess.py", line 524, in run
     raise CalledProcessError(retcode, process.args,
 subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', "import sys;from setuptools.extern.packaging.specifiers import SpecifierSet;from distutils.core import run_setup;dist = run_setup(    'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = {    key: value for key, value in dist.__dict__.items()     if (        not key.startswith('_') and         not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data['metadata'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))"]' returned non-zero exit status 1.

Compilation finally fails with the following:

Starting >>> IntelFortranImplicit -- stderr: FortranCInterface CMake Error at CMakeLists.txt:5 (project): No CMAKE_Fortran_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "FC" or the CMake cache entry CMAKE_Fortran_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. Failed

The same errors occur when using humble rather than rolling.

when I add gfortran to the apt install list, I get another error:

Starting >>> lit WARNING:colcon.colcon_cmake.task.cmake.build:Could not run installation step for package 'IntelFortranImplicit' because it has no 'install' target Finished >> my-test-package stderr: lit CMake Warning (dev) in CMakeLists.txt: No project() command is present. The top-level CMakeLists.txt file must contain a literal, direct call to the project() command. Add a line of code such as project(ProjectName) near the top of the file, but after cmake_minimum_required(). CMake is pretending there is a "project(Project)" command on the first line. This warning is for project developers. Use -Wno-dev to suppress it. CMake Error at CMakeLists.txt:4 (configure_lit_site_cfg): Unknown CMake command "configure_lit_site_cfg". CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 3.22) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it. Failed

I don't know what lit or my-test-package are.

Additional information

  • I couldn't determine what depends on Fortran with certainty and searching the ros2 org didn't yield any results, so this issue might be elsewhere or with documentation.
  • I looked at the official docker images but they install the binary packages from apt rather than build from source.
  • question while I'm here: If I want to develop on one of the component libraries (say rclpy), is building everything from source the recommended approach? Is there a way to use the prebuilt docker images ros:rolling and then clone just rclpy
  • related issue on ros2 issue tracker

Originally posted by achille on ROS Answers with karma: 464 on 2023-01-24

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You're executing a colcon operation in the root of the container's filesystem.

The default value for colcon's --base-paths argument is actually ., not src. This is why colcon marks the build, install, and log subdirectories of the workspace with COLCON_IGNORE.

You could modify the colcon invocation with --base-paths src, but it would be better to create an empty subdirectory in the container to to serve as the workspace rather than dumping all of these files directly in /.

To explain why this is failing, colcon is crawling the entire filesystem and finds things that look an awful lot like packages, and then it tries to build them and unsurprisingly fails to do so.

EDIT: Here's the section of the installation instructions where a new directory is created for the workspace: https://docs.ros.org/en/rolling/Installation/Alternatives/Ubuntu-Development-Setup.html#get-ros-2-code


Originally posted by cottsay with karma: 311 on 2023-01-24

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by achille on 2023-01-25:
Great find, thanks! It's curious to me that the default isn't src but perhaps there's an explanation for that.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.