# Change colors of Pkg.test()

**URL:** <https://discourse.julialang.org/t/change-colors-of-pkg-test/66369>\
**Category:** New to Julia\
**Tags:** repl\
**Created:** [August 13, 2021, 10:04pm UTC](https://discourse.julialang.org/t/change-colors-of-pkg-test/66369 "2021-08-13T22:04:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [August 13, 2021, 10:04pm UTC](https://discourse.julialang.org/t/change-colors-of-pkg-test/66369/1 "2021-08-13T22:04:23Z")

</div>

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

![image](https://global.discourse-cdn.com/julialang/original/3X/a/5/a5022215fe3e3b9bb451f282f60782f6b09add51.png)

I’ve tried setting the environment variables in [Environment Variables · The Julia Language](https://docs.julialang.org/en/v1/manual/environment-variables/#REPL-formatting), 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.

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [August 13, 2021, 10:09pm UTC](https://discourse.julialang.org/t/change-colors-of-pkg-test/66369/2 "2021-08-13T22:09:37Z")

</div>

Also, what are the different shades of gray here:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/4/84bd619c080ec356397ad60d2aa841467094dad9.png)

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [August 13, 2021, 10:46pm UTC](https://discourse.julialang.org/t/change-colors-of-pkg-test/66369/3 "2021-08-13T22:46:04Z")

</div>

Huh. Seems like these are hard-coded: [https://github.com/JuliaLang/julia/blob/73e552200372781c80045776d087d0c82707163f/stdlib/Test/src/Test.jl#L995](https://github.com/JuliaLang/julia/blob/73e552200372781c80045776d087d0c82707163f/stdlib/Test/src/Test.jl#L995)

So everybody just uses dark background terminals? 👎

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [August 13, 2021, 11:32pm UTC](https://discourse.julialang.org/t/change-colors-of-pkg-test/66369/4 "2021-08-13T23:32:38Z")

</div>

A partial workaround is described in [https://github.com/JuliaLang/julia/issues/41791#issuecomment-893275428](https://github.com/JuliaLang/julia/issues/41791#issuecomment-893275428)

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

---

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [August 14, 2021, 12:13am UTC](https://discourse.julialang.org/t/change-colors-of-pkg-test/66369/5 "2021-08-14T00:13:29Z")

</div>

> [@goerz](#):
>
> 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

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [August 14, 2021, 1:40am UTC](https://discourse.julialang.org/t/change-colors-of-pkg-test/66369/6 "2021-08-14T01:40:51Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 16, 2021, 7:48am UTC](https://discourse.julialang.org/t/change-colors-of-pkg-test/66369/7 "2021-08-16T07:48:27Z")

</div>

> [@goerz](#):
>
> 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.

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: [Updating the Windows Console Colors - Windows Command Line](https://devblogs.microsoft.com/commandline/updating-the-windows-console-colors/).

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.
