Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal width lookup fails unnecessarily if terminfo unpopulated #2332

Open
hseg opened this issue Feb 23, 2025 · 1 comment
Open

Terminal width lookup fails unnecessarily if terminfo unpopulated #2332

hseg opened this issue Feb 23, 2025 · 1 comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike.

Comments

@hseg
Copy link
Contributor

hseg commented Feb 23, 2025

(Note: Very niche reproducer)

As noted in https://github.com/simonmichael/hledger/blob/master/hledger/Hledger/Cli/CliOptions.hs#L626, ifthe terminfo entry for $TERM can't be read, setupTermFromEnv throws an error. In particular, I'm encountering this when building hledger in a clean chroot that contains all its build dependencies, but doesn't contain the terminfo definitions for the terminal (kitty) I'm running the chrooted build in.

I'm a little loath to add kitty to the chroot unnecessarily, especially in view of the fact that hledger doesn't actually need an entire terminfo entry, just enough to tell the number of columns in the terminal. Given that the tests also pass with TERM=dumb, I'm guessing that its fallback settings are widely supported enough to work as an alternative.

Hence, I'd either recommend replacing the call to setupTermFromEnv with

setupTermFromEnv `catch` \(_ :: SetupTermError) -> setupTerm "dumb"

or document this dependency on TERM being valid somewhere (perhaps this ticket suffices).

For my part, I'm adding TERM="dumb" to my packaging script until this is fixed (much like I'd set LANG=C to reset to a known-good situation).

@simonmichael
Copy link
Owner

Thanks for the report and suggestion. Is it something you could try to implement, @hseg ?

@simonmichael simonmichael added A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike. labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike.
Projects
None yet
Development

No branches or pull requests

2 participants