Skip to content

Nix Hledger and GHC using ascii to read hledger file. Should be using utf8 proposal for documentation #2089

@alexiscott

Description

@alexiscott

Using linux-x86_64 with a fresh install of Ubuntu Lunar 23.04.
GHC 9.4.6 installed via the Nix package manager.
Hledger also installed via Nix, at 1.30.1.

Problem
Running hledger bs on a file containing € characters:
hGetContents: invalid argument (cannot decode byte sequence starting from 226)

Solution

€ is a utf8 character and so should be treated as utf8 not ascii.

My solution, based on Nix issue NixOS/nixpkgs#64603 and Nix documentation https://nixos.org/manual/nixpkgs/stable/#locales was to update my ~.profile with:

export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive

And restart computer, or > source ~/.profile

After that hledger bs was correctly reporting my balance.

Proposed documentation update in manual

In the manual, it might be worth adding this Nix specific case:

If you are using Nix (not NixOS) for GHC and Hledger, you might need to set the LOCALE_ARCHIVE variable
$ echo "export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive" >>~/.profile
# close and re-open terminal window

Which could go underneath where you currently have:
$ echo "export LANG=en_US.utf8" >>~/.profile
# close and re-open terminal window

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.docsDocumentation-related.i18nInternationalisation/localisation-related.platform-linuxplatform-nix

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions