colcon / colcon-ros

Extension for colcon to support ROS packages
http://colcon.readthedocs.io
Apache License 2.0
13 stars 26 forks source link

`gcc` FileNotFoundError #130

Closed baszalmstra closed 3 months ago

baszalmstra commented 2 years ago

When building in an environment where gcc is not named gcc but something different like x86_64-conda-linux-gnu-cc. colcon-ros errors with this error at the end of a build:

Traceback (most recent call last):
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/site-packages/colcon_core/executor/__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/site-packages/colcon_core/task/__init__.py", line 93, in __call__
    return await task_method(*args, **kwargs)
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/site-packages/colcon_ros/task/catkin/build.py", line 98, in build
    additional_hooks += create_pkg_config_path_environment_hooks(
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/site-packages/colcon_ros/task/cmake/__init__.py", line 24, in create_pkg_config_path_environment_hooks
    multiarch = get_multiarch()
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/site-packages/colcon_ros/task/cmake/__init__.py", line 46, in get_multiarch
    output = subprocess.check_output(['gcc', '-print-multiarch'])
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/builds/.workspace-aa0dc32c/.env/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gcc'

An error is caught here but not the FileNotFound error.

I don't know exactly what the best approach is. We could either use the $CC variable but that might not refer to a GCC compiler, or catch the FileNotFoundError and rely on the backup of using dpkg-architecture.