Change colors of Pkg.test()

How do I change the colors for all the different elements in the output of Pkg.test()?


I’ve tried setting the environment variables in Environment Variables · The Julia Language, but they don’t seem to have the desired effect. Moreover, I’m not sure what is what. The “Fail” is probably “JULIA_ERROR_COLOR” and the “Total” might be “JULIA_INFO_COLOR”, but what is “Pass”, “Broken”, and the light gray text in the top left?

Also, generally speaking, it would be really great if Julia didn’t default to colors that only work in a dark background terminal. I know this is difficult with 16 color terminals, but maybe it could detect if it runs in at least a 256 color environment. There, it should be possible to choose default colors that work equally well on a light and dark background.

Also, what are the different shades of gray here:

1 Like

Huh. Seems like these are hard-coded: julia/Test.jl at 73e552200372781c80045776d087d0c82707163f · JuliaLang/julia · GitHub

So everybody just uses dark background terminals? :-1:

1 Like

A partial workaround is described in Provide entry point for color customization · Issue #41791 · JuliaLang/julia · GitHub

However, Pkg.test() seems to ignore/overwrite any such settings, whereas it works for include("tests/runtests.jl") from a normal REPL.

That’s because Pkg.test uses a subprocess sandbox and those overrides aren’t explicitly passed to the subprocess. Handling that would be a good requirement of the issue/FR you linked

1 Like

Right… since I have the color overwrites in my startup.jl file, the key is to explicitly start the julia with --startup-file=yes. In that case, Pkg.test also picks up the startup file and thus the patched colors. This is actually explained in ?Pkg.test


The 16 base colors are set by the current theme of your terminal. Windows cmd had a bad default theme that made some colors not really readable (and that is with black background). So they updated their defaults:

In the same vein, if you have picked a theme such that there are base colors that are unreadable on your terminal, I suggest picking a better one.

1 Like