New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perl warning: setting locale failed #8398

Closed
andrewrk opened this Issue Jun 19, 2015 · 11 comments

Comments

Projects
None yet
10 participants
@andrewrk
Copy link
Contributor

andrewrk commented Jun 19, 2015

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

@edolstra

This comment has been minimized.

Copy link
Member

edolstra commented Jun 19, 2015

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

@andrewrk

This comment has been minimized.

Copy link
Contributor Author

andrewrk commented Jun 19, 2015

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

@edolstra

This comment has been minimized.

Copy link
Member

edolstra commented Jun 19, 2015

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

@andrewrk

This comment has been minimized.

Copy link
Contributor Author

andrewrk commented Jun 19, 2015

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

@aragnon

This comment has been minimized.

Copy link

aragnon commented Dec 10, 2015

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

@joepie91

This comment has been minimized.

Copy link
Contributor

joepie91 commented Feb 21, 2016

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.

@dezgeg

This comment has been minimized.

Copy link
Contributor

dezgeg commented Feb 21, 2016

For those who are getting this outside NixOS, NixOS/nix#599 is likely related.

@davorb

This comment has been minimized.

Copy link
Contributor

davorb commented Oct 4, 2016

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
@instantepiphany

This comment has been minimized.

Copy link

instantepiphany commented Jul 24, 2017

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.

drewr added a commit to drewr/dotfiles that referenced this issue Sep 15, 2017

@nbp

This comment has been minimized.

Copy link
Member

nbp commented May 28, 2018

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.

@domenkozar

This comment has been minimized.

Copy link
Member

domenkozar commented Sep 6, 2018

merging into #38991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment