Nix package manager: perl warning: Setting locale failed

localenixnixosopensuseperl

Whenever I run a command for the nix package manager (e.g. nix-channel –update) I get the following warning:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = "en_US.UTF-8",
        LC_CTYPE = "en_US.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

I suspect it's somehow related to nix since other perl scripts don't show this behaviour (I tried perl -e exit and something using WWW::Curl).

Changing the locale settings does reflect in the output of the warning, but the warning is still shown with every configuration I could think of.

OS is openSUSE.

What can I do?

Best Answer

Apparently this is a problem in nix. There is an issue on GitHub with a proposed workaround by setting the LOCALE_ARCHIVE variable.

If you already have nix installed just do:

  1. nix-env -iA nixpkgs.glibcLocales

  2. And in your bash profile:

    export LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive"

    (all as one line).