`gh api` not using `$PAGER` correctly
jwodder opened this issue · 7 comments
OS: macOS Sonoma 14.4.1
gh version: 2.48.0 (installed via Homebrew)
I have the environment variables PAGER=/usr/bin/less
and LESS=-iRS
(but not GH_PAGER
) set in my shell. Starting sometime maybe in the last month, whenever I run gh api
without any output redirection, the program will start less
to show the output, but the screen will show the last lines of the output rather than the start of the output, and if I then press any key, the output disappears, to be replaced by a tilde on each line (which is how less
displays empty input). I think this problem is caused by mixing up stdout and stderr, but I'm unable to come up with an MVCE.
If I unset PAGER
, gh api
will output to stdout correctly. If I unset LESS
instead, gh api
still outputs to stdout without invoking less
.
Uh oh! Any chance you could capture this in a screen recording to help me better understand what you're seeing! It would be very interesting to know if this reproduced in v2.47.0
, v2.46.0
and v2.45.0
if you're up for doing some spelunking! How often does it reproduce?
Any chance you could capture this in a screen recording to help me better understand what you're seeing!
Here are two asciinema recordings; the first one involves more than a screenful of output, while the second involves less than a screenful. In both cases, all I did inside less
was press g
(which should have taken me to the top of the output but instead cleared the output) and then q
to quit.
It would be very interesting to know if this reproduced in
v2.47.0
,v2.46.0
andv2.45.0
if you're up for doing some spelunking!
I downloaded the macOS amd64 release assets for each of those versions from the Releases page, and none of them exhibited the bug. Just to be sure this wasn't Homebrew's fault, I also downloaded the 2.48.0 asset from the Releases page, and it still has the buggy behavior.
How often does it reproduce?
Every time I've used gh api
for the past month or so (assuming PAGER
and LESS
are set and there's no output redirection etc.)
@williammartin I'm currently debugging this and trying both v2.47.0 and v2.48.0 to see what's causing this. So far, everything is the same between the two (for this specific scenario where the newly introduced jsonArrayWriter
is not used). Will update you soon.
@williammartin I just submitted #9020 to fix this. The change that caused this in v2.48.0, was the calling of StartPager
method at a later stage.
And sorry because it's not yet marked as help-wanted
. I thought this way it's easier for you to see the changes.