Skip to content

styx sets invalid value for LANG environment variable #16

Description

@juliapath

How to reproduce

  1. Create a styx project
    $ mkdir test
    $ cd test
    $ cabal init -n
    ...
    $ cat <<here > styx.yaml
    local-packages:
      test:
        location: .
    here
    $ styx configure
    
  2. Watch the problems
    $ nix-shell .styx/shell.nix --pure
    nix$ echo $LANG
    en_US.UTF-8
    nix$ locale -a
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_MESSAGES to default locale: No such file or directory
    locale: Cannot set LC_COLLATE to default locale: No such file or directory
    C
    C.utf8
    POSIX
    nix$ ghci
    Prelude> getLine
    ä*** Exception: <stdin>: hGetLine: invalid argument (invalid byte sequence)
    
    Note how en_US.UTF-8 is not listed in the available locales given by locale -a. The Cannot set ... error messages by locale -a are also due to the invalid value of LANG. Furthermore Haskell functions like getLine will assume the character encoding to be ASCI, causing them to throw exceptions on non ASCI characters.

Solutions

There are two possible solutions:

  1. Set LANG=C.UTF-8
  2. Add glibcLocales to buildInputs to make more locales available. This can be done easily as a workaround by adding glibcLocales to non-haskell-deps in styx.yaml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions