Disable Colorization on Mongosh

Hello everyone!

So, I had just made the move to Mongo 5.0.23 from 4.4, which also means we’ve made the move to from mongo to mongosh.

Now, the people who I am supporting are not big fans of the syntax colorization that Mongo Shell uses since some of the font is a lot harder to read (yellow text on white background) and requested that I make it monochrome.

I’ve been able to get it to remove most colors by setting the environment variable NO_COLOR to 1. However, it doesn’t seem that Mongo shell is fully honoring this variable; Things such as deprecation messages, error messages or pretty much anything between quotes gets colorized.

I’ve attempted to set my term to both “dumb” and “xterm-mono” and the output still comes out colorized on Mongo (even if it’s colorized on no other program).

I’ve searched all over for any other person with this same problem and had only found a reddit post with the NO_COLOR suggestion. I couldn’t find anything in Mongo’s documentation, either.

I’m at my wit’s end here. Does anyone happen to know of a way to turn this off?

I’m using Debian 11 and am using bash shell, if that helps. I apologize if I omitted any important details.

Thanks in advance!

@Peahat you raise an interesting question!
Mongosh’s AI doc search bot insists there is no way to do this.
However, this may be an accessibility issue as color-blind persons might have great difficulty, not merely annoyance, with colorized responses.
Perhaps you could go to the MongoDB Issue Tracker and open an Accessibility issue.

1 Like

I see! I’m both glad to know that I hadn’t overlooked something obvious, while also a little sad that it’s not a simple fix.

Thanks, Jack, I’ll go ahead and post on the issue tracker and will see if they can add in this fix.

Thank you!

2 Likes

Try this query in the issue tracker: https://jira.mongodb.org/browse/MONGOSH-724?jql=project%20%3D%20MONGOSH%20AND%20text%20~%20"color"
It seems to be relevant.

1 Like

I finally got around to posting the ticket with Mongo.

This turns out to be a bug, after all, which they intend on working on.

As a temporary workaround, they provided me with the alternate variable:
NODE_DISABLE_COLORS=1

It does exactly what we need! Thanks again everyone for your help!

1 Like

Thanks @Peahat!

Have you got the JIRA link handy for anyone else who come looking in the future?

Of course, Chris… my bad!

Here it is: https://jira.mongodb.org/browse/MONGOSH-1691

1 Like

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