Conflict between glibc and glibcLocales? (TL;DR I messed it up)

I just did a fresh install of NixOS (unstable channel) and I get errors like:

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

Since I just configured locale with i18n.defaultLocale and it’s a fresh install I don’t think this is relevant: glibc 2.27 breaks locale support · Issue #38991 · NixOS/nixpkgs · GitHub

Then I noticed that there’s something weird in the system-path build logs:

collision between `/nix/store/7ymwv89lvf5mrm9nqpm8i7cnbyx8fqka-glibc-locales-2.30/lib/locale/locale-archive' and `/nix/store/jx19wa4xlh9n4324xdl9rjnykd19mmq3-glibc-2.30/lib
/locale/locale-archive'

Therefore…

Workaround

Indeed, raising the priority of glibcLocales seems to fix this:

# (Based on the default value)

i18n.glibcLocales = lib.hiPrio (pkgs.buildPackages.glibcLocales.override {
  allLocales = lib.any (x: x == "all") config.i18n.supportedLocales;
  locales = config.i18n.supportedLocales;
});

As I didn’t find anything in the issue tracker other than what I found above, and that also didn’t mention conflicts AFAICT, I’m tempted to report an issue, but I thought I can’t be the only one to notice an issue with such a basic package. Any ideas on this? Anything I can do?

My configuration is at https://github.com/dramforever/config/tree/master/nixos (includes the workaround)

2 Likes

Ah, right. This is because we added this builtin C.UTF-8 locale.
Most people won’t suffer from this because they don’t add glibc into their systemPackages.

To me it seems a strange thing to do – typically people explicitly install such packages “by mistake” due to their use case much better covered by other ways like nix-shell.

I suppose we could simply do the hiPrio for i18n.glibcLocales by default.

That was it! I had this config for a while and I originally had glibc there so that I could patchelf executables and point their interpreters at a stable location. It works if the executable doesn’t need other libraries, like cpptools. Pretty I checked the relevant module but I didn’t notice it. Thanks for taking a look.

To me it seems a strange thing to do – typically people explicitly install such packages “by mistake” due to their use case much better covered by other ways like nix-shell .

Indeed I now think it’s a mistake on my side. I don’t really think making i18n.glibcLocales hiPrio is necessary.

I can’t see any reason not to increase the priority here:
https://github.com/NixOS/nixpkgs/pull/90128

I guess I don’t really need this, but considering that we do have conflicting files, it’s probably be a good idea to raise the priority of glibcLocales.

I was getting the same error with sloccount, so I opened this:

https://github.com/NixOS/nixpkgs/pull/89891

Although that PR seems to break things (strange, I’m using it here, but that’s a separate issue).