Skip to main content

Configure Your Colcon

To improve your life, we'll setup some flags that will be used with each colcon build using mixin.

sudo apt install python3-colcon-mixin

colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
colcon mixin add mrs https://raw.githubusercontent.com/ctu-mrs/colcon_mixin/refs/heads/master/index.yaml
colcon mixin update

Create a config file and copy the following build flags.

cd ~/ros2_ws

touch colcon_defaults.yaml
build:
symlink-install: True # link configs and other files to install folder
continue-on-error: True # build the rest of the packages if one fails
executor: parallel # enable parallel package building
parallel-workers: 4 # maximum packages build in parallel (increase if good CPU)
mixin:
- rel-with-deb-info # display more info when failed
- compile-commands # generate compile commands

By default, colcon uses a monochromatic output that is poorly readable. To add some colors and order, install the following extenstion.

pip install git+https://github.com/cottsay/colcon-ansi-colors-example --break-system-packages

Put the build option to your ~/.bashrc (or ~/.zshrc) to use it by default.

export COLCON_DEFAULT_OUTPUT_STYLE=catkin_tools

Open a new terminal and try building your workspace again.