[colcon] Adding a verb 'clean' to colcon?

Hey everyone,

We use ROS 2 at my company to develop robotic applications. From time to time, we have the need to remove everything and do a fresh build (for mostly CI reasons).

Does the community feel the need to add an extra verb to the colcon tool, something akin to colcon clean? I take inspiration from make, where we would write a rule to clean the build directory.

Since this issue is related to the colcon tool, and not ROS 2 in general, the mods may move it to a more appropriate place if they so desire. I want to know two things:

  1. Do you think this idea has merit to be put into colcon?
  2. What other “features” have you hacked along that you use daily in your development?

It could very well be the case that a lot of people have thought about this, and maybe this already exists in colcon. If that is the case, I would love to be educated on it.


I don’t want to be that guy, but this was the first result Google gave me after searching for colcon clean :slight_smile:

I had thought so :smiley:
What I found a bit weird was the fact that this is not a part of the colcon toolset by default.

Would still love to know about 'hacky scripts` if you use any for your ROS development

colcon allows you to install (and create) extensions that can be useful.
colcon-clean here is an extension and an example of that.

That extension is distributed over PyPI, see here. Meaning that to install that extension simply do: pip install colcon-clean

After that, check your new option by doing colcon --help: The clean verb should be an option now.

1 Like

Thank you for letting me know about this. I’ll have to try it out today.

On a side note, I really admire this way of adding extensions over to an existing tool :slightly_smiling_face:

Author of colcon-clean here, glad to see the extension fulfilling it’s niche. If you’d like to checkout another case example, this ROSCon talk presents it in more detail, as well as its integration into Nav2’s CI:

Another colcon extension I wrote is for caching workspace artifacts, to save valuable or costly CI time when building or testing. This is also presented in the same talk liked above, with the repo currently found here:

Example demo using both colcon cache & clean together:



This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.