Skip to content

Terminal width lookup fails unnecessarily if terminfo unpopulated #2332

Closed

Description

@hseg

(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).

Activity

  1. simonmichael commented on Feb 25, 2025

    @simonmichael
    Member

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

  2. added
    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.
    cliCommand line parsing, options, arguments and suchlike.
    on Feb 25, 2025
  3. simonmichael commented on Feb 28, 2025

    @simonmichael
    Member

    Now fixed thanks to #2340 I believe ?

  4. hseg commented on Feb 28, 2025

    @hseg
    ContributorAuthor
  5. simonmichael commented on Feb 28, 2025

    @simonmichael
    Member

    I merged it in a funny way (which is not my preference, but sometimes I don't know how to avoid it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.cliCommand line parsing, options, arguments and suchlike.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions