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

Colcon Build fails on newly created package

asked 2020-12-20 09:34:30 -0600

ajtoth gravatar image

I'm starting my first ROS2 project. I followed the tutorial to create a workspace: https://index.ros.org/doc/ros2/Tutori... Then moved on to the tutorial to create my own package: https://index.ros.org/doc/ros2/Tutori... At Step 2 of the "Create my own package" -That is, to say I ran

source ~/ros2_foxy/install/setup.bash
mkdir -p jeri_ws/src
cd jeri_ws/src
ros2 pkg create --build-type ament_cmake jeri_base
cd ..
colcon build

(This passed no problem) But then I realized I wanted the skeleton of the "node" flag, so I found an answer answers.ros.org/question/330109/ros2-... saying to delete the folders created by ros2 pkg create and re-attempt. No problem.

cd ~/jeri_ws
rm -r build logs install
cd src
rm -r jeri_base
ros2 pkg create --build-type ament_cmake --node-name hello-world_node jeri_base
cd ..
colcon build

Then I get the following error:

Traceback (most recent call last):ngoing] [examples_rclcpp_multithreaded_executor:build 100% - 1min 32.0s] ...
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.6/distutils/core.py", line 227, in run_setup
    script_name)
RuntimeError: 'distutils.core.setup()' was never called -- perhaps 'setup.py' is not a Distutils setup script?
--- stderr: jeri_base                                                                                         
Traceback (most recent call last):
  File "/home/jetbot/.local/lib/python3.6/site-packages/colcon_core/executor/__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)
  File "/home/jetbot/.local/lib/python3.6/site-packages/colcon_core/task/__init__.py", line 93, in __call__
    return await task_method(*args, **kwargs)
  File "/home/jetbot/.local/lib/python3.6/site-packages/colcon_ros/task/ament_python/build.py", line 51, in build
    setup_py_data = get_setup_data(self.context.pkg, env)
  File "/home/jetbot/.local/lib/python3.6/site-packages/colcon_core/task/python/__init__.py", line 20, in get_setup_data
    return dict(pkg.metadata[key](env))
  File "/home/jetbot/.local/lib/python3.6/site-packages/colcon_ros/package_identification/ros.py", line 130, in getter
    desc.path / 'setup.py', env=env)
  File "/home/jetbot/.local/lib/python3.6/site-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 242, in get_setup_information
    setup_py, env=env)
  File "/home/jetbot/.local/lib/python3.6/site-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 283, in _get_setup_information
    cwd=os.path.abspath(str(setup_py.parent)), check=True, env=env)
  File "/usr/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
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.
---
Failed   <<< jeri_base [6.52s, exited with code 1]
Aborted  <<< turtlesim [5.80s]
Aborted  <<< examples_rclcpp_multithreaded_executor [1min 32s]
Aborted  <<< examples_rclpy_minimal_subscriber [20.1s]

Summary: 14 packages finished [2min 20s]
  1 package failed ...
(more)
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2020-12-29 11:50:51 -0600

ajtoth gravatar image

Instead of installing from apt, I built from source, building in ~/ros2_foxy according to the tutorial https://index.ros.org/doc/ros2/Instal...

I solved the problem: the tutorial specifies that you need to run commands in a new terminal. I skimmed over those instructions. When I deleted my workspace (rm) and ran every block in its own SSH session, it worked no problem.

edit flag offensive delete link more
1

answered 2022-02-17 08:22:49 -0600

omerts gravatar image

After also struggling with this, you won't believe the solution. It is the hyphen "-" in the package name. Change hello-world_node to hello_world_node, and it will work.

edit flag offensive delete link more
0

answered 2020-12-20 10:04:18 -0600

Kajack gravatar image

I had a similar experience. It was caused by running the ros2 create in the wrong folder and just generally doing several things in the wrong folder. Then I found this tutorial which may not be very relevant to whot your are trying to code, but this tutorial explicitly tells you where to run create and colcon commands. Your first line line looks suspicious where you had ...

source ~/ros2_foxy/install/setup.bash

Mine typically looks like ....

source /opt/ros/foxy/setup.bash

I use the default installed file instead of copying to several places. So try this tutorial on a new project, paying attention to the folders used in each step. https://index.ros.org/doc/ros2/Tutori...

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-12-20 09:34:30 -0600

Seen: 6,455 times

Last updated: Dec 20 '20