10

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?

8
  • What about perl -w -e exit?
    – goldilocks
    Feb 28, 2015 at 16:10
  • No warning either
    – hrantzsch
    Feb 28, 2015 at 16:22
  • 1
    Just remembered where I've seen this before. Have a look at my answer to this question and see if it works for you.
    – goldilocks
    Mar 1, 2015 at 12:57
  • Hm, these files don't exist on my system. Also, openSUSE doesn't have locale-gen. I never had to deal with locales, so I'll go to the openSUSE forums and ask what's the intended way to configure this on this system. I find it still strange that I only get this error when running nix commands and not when directly running perl commands.
    – hrantzsch
    Mar 1, 2015 at 19:47
  • 1
    Have you had a look at this? locale-gen turns out to just be a shell script that wraps localedef, which probably is on your system (it's on fedora, which also doesn't use locale-gen, and it's POSIX). I'd rather visit the dentist though ;) The locale-gen script is pretty short but you'll have to pull it off a debian derived system or download a .deb to look at it.
    – goldilocks
    Mar 1, 2015 at 20:01

3 Answers 3

11

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

1
  • 1
    I think this may be nixpkgs.glibcLocales, not nixpkgs.glibc-locales. Jun 25, 2018 at 18:55
4

With export LC_ALL=C I actually got rid of the warning.

This is more of a workaround (as LC_ALL is also strongly discouraged), but my guess is the reason for this behaviour lies in assumptions nix makes about locales on the system which don't apply on openSUSE.

1

Found this during a search and thought I'd give the solution.

You just need to provide the variable LOCALE_ARCHIVE in the environment pointing to a locale-archive.

Option 1

Use a previously installed system locale-archive.

Make sure it's actually there

# should find the file
ls /lib/locale/locale-archive

Add this to your /etc/.profile and/or ~/.bashrc/ and/or ~/.zshrc to have it always set in your shell:

export LOCALE_ARCHIVE="/lib/locale/locale-archive"

Option 2a : Without flake + sub-command support

(source: cyraxjoe above https://unix.stackexchange.com/a/243189/119561)

Install locale support from nix.

nix-env -iA nixpkgs.glibcLocales

Make sure you can find it:

# should give you a path to a folder in your /nix/store
nix-env --installed --no-name --out-path --query glibc-locales

# should find the file
ls $(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive

Add this to your /etc/.profile and/or ~/.bashrc/ and/or ~/.zshrc to have it always set in your shell:

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

Option 2b : With flake + sub-command support

Install locale support from nix.

nix profile install nixpkgs#glibcLocales

Make sure you can find it:

# should give you a path to a folder in your /nix/store
nix profile list | grep glibcLocales | tail -n1 | cut -d ' ' -f4

# should find the file
ls $(nix profile list | grep glibcLocales | tail -n1 | cut -d ' ' -f4)/lib/locale/locale-archive

Add this to your /etc/.profile and/or ~/.bashrc/ and/or ~/.zshrc to have it always set in your shell:

export LOCALE_ARCHIVE="$(nix profile list | grep glibcLocales | tail -n1 | cut -d ' ' -f4)/lib/locale/locale-archive"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .