Nixpkgs: perl warning: setting locale failed

Created on 19 Jun 2015  Â·  14Comments  Â·  Source: NixOS/nixpkgs

When some perl scripts are run, this warning message is outputted:

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

Here's my nix configuration: https://github.com/andrewrk/dotfiles/blob/e3bf84568abe49af84c5bb45c0954d3a1d5f73fa/nixconfigs/configuration.nix

bug

Most helpful comment

Ran into this issue on openSUSE Leap 42.1 as well, and it actually broke the installation of the Brackets package for me. This workaround worked for me:

nix-env -iA nixpkgs.glibcLocales

Then add the following to the end of your .bashrc:

export LOCALE_ARCHIVE="$(readlink ~/.nix-profile/lib/locale)/locale-archive"

Then restart your shell, and reinstall the package if needed. Not sure how to do the latter correctly - I went for the nuclear option by removing the store paths and running a repair, but that might have undesirable consequences. Perhaps @edolstra can clarify on the correct way to do this?

I don't know whether this workaround affects non-Nix stuff - as far as I can tell, $LOCALE_ARCHIVE is a Nix thing.

I do agree that this seems like a source of impurity, and should probably be fixed somehow.

Ref #6878.

All 14 comments

Make sure $LOCALE_ARCHIVE is set in the context where you're running those scripts.

Pardon my ignorance, but could you link to some documentation about what LOCALE_ARCHIVE is and what value it should be set to?

On NixOS, it should be set to /run/current-system/sw/lib/locale/locale-archive.

[nix-shell:~]$ echo $LOCALE_ARCHIVE
/run/current-system/sw/lib/locale/locale-archive

In this example I'm building some stuff with mxe but I'll see if I can come up with a simpler test case for reproducing the problem.

On Ubuntu, I also get this. IMHO, this is a source of impurity, which should be eliminated.

Ran into this issue on openSUSE Leap 42.1 as well, and it actually broke the installation of the Brackets package for me. This workaround worked for me:

nix-env -iA nixpkgs.glibcLocales

Then add the following to the end of your .bashrc:

export LOCALE_ARCHIVE="$(readlink ~/.nix-profile/lib/locale)/locale-archive"

Then restart your shell, and reinstall the package if needed. Not sure how to do the latter correctly - I went for the nuclear option by removing the store paths and running a repair, but that might have undesirable consequences. Perhaps @edolstra can clarify on the correct way to do this?

I don't know whether this workaround affects non-Nix stuff - as far as I can tell, $LOCALE_ARCHIVE is a Nix thing.

I do agree that this seems like a source of impurity, and should probably be fixed somehow.

Ref #6878.

For those who are getting this outside NixOS, https://github.com/NixOS/nix/issues/599 is likely related.

In case anyone else is having this issue, I fixed it by adding the following to my .zshrc:

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

To add visibility in search engines, I was experiencing this issue with non-perl programs - bash and python to be specific. The cause for me, I believe, is that I have my system (NixOS) following the stable channel, but my user environment following the unstable channel. My theory (I don't have any understanding of locale settings or (nixos|nixpkgs).glibcLocales) is that my user environment (unstable) derivations were not compatible with the system locales from the stable channel.

Following @joepie91's suggestion above fixed my problem.

I have the same issue and @joepie91 suggestion did not work for me.
Running nix-env -u \* fixed a few issues with grep and git grep, but I still have the perl error message which makes mosh unusable.

-- Edit:

@joepie91's solution does work, but for reasons which are unknown to me, if it is not installed as part of the profile then this does not work. Just setting the environment variable does not work.

@joepie91 fix seemed to work for me. I'm just using nix-env and I'm confused about how this issue arose. I'm new to Nix, but my limited understanding gave me confidence that installations should bundle every dependency they needed to run properly. Needing to set LOCALE_ARCHIVE in my ~/.profile (of all places) feels like a leaky workaround, which makes me uncomfortable.

Can someone help me better understand what exactly is going on? I've read in other threads that this is an issue with glibc version 2.27. That's about all I understand at the moment. Any pointers would be greatly appreciated.

Adding a comment here, at least for future me.

When updating NixOS, mosh no longer works and raises the issue mentioned above.
The solution is to update mosh as well, with nix-env -u mosh --leq to update its perl dependency and fix this issue, as it is installed in user-land and not with NixOS.

export LOCALE_ARCHIVE="$(readlink ~/.nix-profile/lib/locale)/locale-archive"

This file does not exist on my installation.

$ ls ~/.nix-profile/lib/                                                                  Tue 10:22
  libnixexpr.so      libnixmain.so     libnixutil.so    pkgconfig
  libnixformat.so    libnixstore.so    perl5            systemd
Was this page helpful?
0 / 5 - 0 ratings

Related issues

spacekitteh picture spacekitteh  Â·  3Comments

sid-kap picture sid-kap  Â·  3Comments

vaibhavsagar picture vaibhavsagar  Â·  3Comments

ghost picture ghost  Â·  3Comments

rzetterberg picture rzetterberg  Â·  3Comments