arduino/arduino-cli

fdiagnostics-color in extra_flags causes break in library resolver

Opened this issue · 0 comments

Describe the problem

When -fdiagnostics-color=always is added as part of the build extra flags, the library resolver/processor is unable to resolve any libraries.

This is because, if I copy the output to the clipboard, the resolver seems to include the ANSI escape code in the library name:

Image

To reproduce

with an example sketch such as

#include <Arduino.h>
#include <SPI.h>

void setup(void){
    Serial.begin(115200);
    Serial.println("HI!");
}

void loop(void){

}

run

arduino-cli compile -v \
	--build-property "compiler.c.extra_flags=-fdiagnostics-color=always" \
	--build-property "compiler.cpp.extra_flags=-fdiagnostics-color=always" \
	--fqbn ArduinoCore-avr:avr:uno \
	testArduinoCliBug.ino

Expected behavior

The ANSI sequence should be escaped/removed from the library

Arduino CLI version

r2843.20e315c2f

Operating system

Linux

Operating system version

Arch Linux

Additional context

From initial code research the most likely candidate for the fault is in internal/arduino/builder/internal/detector/detector.go, possibly in the function IncludesFinderWithRegExp or the thing calling it.

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details