Auditing terminal text color crates usages?


Currently there’re many choices for terminal text colors:

  • libterm (in rustc tree, used by libtest in tree)
  • colored by mackwic (used by syn as dev-dependency and assert_cli) (Thanks to dtolnay pointing this out.)
  • termcolor by BurntSushi (used by ripgrep and many crates)
  • term by Stebalien (API same as libterm, used by rustfmt, clippy and quite a few other crates)
  • ansi_term by ogham (used by clap, exa and quite a few crates)
  • rustc_term which is also an export of in-tree libterm.
  • and some others.

As an example, rustfmt directly depends on term but also pulls in termcolor and ansi_term from dependencies. It works, but i think maybe we can do better?

EDIT: ansi_term has gained windows console support since 0.11 (March 2018).


1 Like

Hi, thank you for the graph! I have a small question for the graph.

We can see that recently there’s a huge increasing number of direct dependencies for colored and ansi_term, and i saw that colored is a dev-dependency of syn, and ansi-term is a dev-dependency of colored.

We all know that syn is very popular, and i’m curious that whether a large part of this increment comes from syn.

And if possible, can we have another graph that excludes all dev-dependencies?


Syn had a dev dependency on colored for less than two months—March 10, 2019 through May 8—so I would not attribute much of what you see to syn’s popularity.

Dev dependencies account for about 5% of total dependencies in this graph so it would look the same. The graph is from cargo tally in case you want to make your own.


@dtolnay Thanks, i just realized the graph is the number of direct dependencies, but i thought it was transitive .


termcolor's API is generally more clumbsy to use, primarily because it specifically supports coloring via the Windows console APIs. If you remove that support, then you’re left with just ANSI escapes. Since ANSI escapes are just bytes embedded in the output sent to a terminal, an API that supports just them can look very different and generally be nicer to use.

Windows 10 does support ANSI escapes, so a lot of folks have seen fit to drop suport for older versions of Windows in exchange for a more convenient API.

I personally know plenty of folks still stuck on Windows 7, so it seems valuable to continue to support them if the cost of doing so is small. Not everyone will agree though.

As for term, it was the first crate in the ecosystem to provide this functionality (and was originally part of the Rust distribution pre 1.0). So a lot of folks are still using it. But I ran into significant issues using it in a multi-threaded program, and also bugs related to using the terminfo stuff. Thus, termcolor was born.

I don’t see this being resolved any time soon.