2025-07-31 Fixing jujutsu and leaky ascii escape sequences on FreeBSD
Jujutsu is a different spin of a scm that happens to use git as a backend. I have been transitioning some of my projects to use jj and it's been relatively smooth until I started to use it more actively on FreeBSD and started to run into issues with what were apparently ansi escape codes with a vanilla installation of jj on FreeBSD.
The Problem
The following is an example highlighting the problem on a FreeBSD system with default configurations for jj.
$ mkdir jjtest
$ cd jjtest
$ jj git init
Initialized repo in "."
$ jj status
The working copy has no changes.
Working copy (@) : ESC[1mESC[38;5;13mrESC[38;5;8mwxzksxpESC[39m ESC[38;5;12maESC[38;5;8md18667fESC[39m ESC[38;5;10m(empty)ESC[39m ESC[38;5;10m(no description set)ESC[0m
Parent commit (@-): ESC[1mESC[38;5;5mzESC[0mESC[38;5;8mzzzzzzzESC[39m ESC[1mESC[38;5;4m0ESC[0mESC[38;5;8m0000000ESC[39m ESC[38;5;2m(empty)ESC[39m ESC[38;5;2m(no description set)ESC[39m
Debugging
At first, I thought it was a terminal issue so tried setting the TERM environment variable to xterm but that still failed which had me confused. I tested it on a Linux system and did not observe the behavior at all. After, fiddling with the TERM environment variable more to no success, I started checking command line options and noticed that jj accepts a --no-pager option so I decided to try that.
$ jj status --no-pager
The working copy has no changes.
Working copy (@) : rwxzksxp ad18667f (empty) (no description set)
Parent commit (@-): zzzzzzzz 00000000 (empty) (no description set)
Looks like that works! I also searched and found the following issues logged against jj that gave a better understanding of what was happening. The bottom issue is the issue that has a more complete explanation however the title of the first issue describes the problem observed problem succinctly.
The following quote from this comment points to the heart of what is happening.
We do try to use less -FRX when it seems that neither the user nor their system configured less. This is a bit error-prone.
Unfortunately, on FreeBSD it triggers this particular error. Subtle issues like these tend to stem from implicitly relying on behaviors from other tools (in this case the less utility). In this case this I am going to attribute this to (yet another) GNU-ism. Luckily, there are ways to mitigate this (besides using --no-pager endlessly). For a set once and forget, there is a configuration option in the global jj config file (usually in ~/.config/jj/config.toml) that will get rid of the ascii escape code spam.
The Solution
Just add the following section in the config and jj will behave on FreeBSD.
# add to ~/.config/jj/config.toml
[ui]
# Disable all pagination, equivalent to using --no-pager
paginate = "never"
I did that myself and am finding jj is working just as happily on FreeBSD as other environments I have been trying it out on. I guess yet another option is to force the use of the GNU version of less but that option doesn't sit well with me, personally.