Pre-RFC: Build scripts colours



This RFC proposes to add a COLOR environment variable to tell build scripts to pass on the colour options.


Currently, crates like cc-rs pipes the output into a buffer, which is not a terminal. This will disable the C compilers from outputting coloured messages. This message is dumped upon error, but without colours it may be harder to figure out what’s going on.


A COLOR environment variable is passed during runtime of build scripts, just like others documented here. Cargo determines whether we should have colours or not by its own mechanism (currently it uses termcolor plus accepting CLI options). The possible values for COLOR are only two: always and never.

Then, the build script or a downstream crate reads this environment variable, and passes the corresponding to the compiler, for instance -fdiagnostics-color option to gcc/clang.


  • Passing arguments to the build scripts: this sound more Unix-ish but argument parsing is normally hard.
  • A few alternatives for the environment variable name: TERMCOLOR, CARGO_COLOR.
  • We can also use 0/1 for the possible values.

Unresolved questions

Does this need a RFC?



Can we use NO_COLOR?



That’s an unrelated concept, and the people who proposed it did it really wrongly IMO. Anyway, this is not a widespread standard to adopt, and using negative instructions can be confusing.

1 Like

closed #4

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