Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use colored compiler output in gitlab CI with ninja

When using -fdiagnostics-color in my compiler options, I receive colorized output in the compiler output (gcc and clang). This also works with ninja when I run on my local computer. Doing the same in a gitlab-CI, the colors are stripped away. Is there a way to get colored compiler output in a gitlab CI?

I tried make instead of ninja and there the colors appear.

like image 811
pseyfert Avatar asked Dec 09 '25 21:12

pseyfert


1 Answers

The problem comes from ninja's output handling (Ninja must interfere with the output to avoid that concurrent processes mix their outputs). While gcc/clang even in the gitlab-CI issue colored output, ninja determines if the output goes to a usual user terminal or a logfile and removes the colors. This is discussed on the ninja github page:

for the smart-terminal detection and color preservation: issue pull request

and somewhat related: another issue another pull request

EDIT: as of this commit (i.e. ninja 1.9.0), the environment variable CLICOLOR_FORCE can be used to disable stripping color codes.

like image 140
pseyfert Avatar answered Dec 12 '25 05:12

pseyfert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!