Skip to content
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

error: selector 'glibc-locales' matches no derivations #183960

Open
tmnvanderberg opened this issue Jul 30, 2022 · 14 comments
Open

error: selector 'glibc-locales' matches no derivations #183960

tmnvanderberg opened this issue Jul 30, 2022 · 14 comments
Labels
0.kind: bug Something is broken

Comments

@tmnvanderberg
Copy link

tmnvanderberg commented Jul 30, 2022

Describe the bug

While running nixos-rebuild switch i get the following output:

building Nix...
building the system configuration...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
activating the configuration...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
setting up /etc...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
reloading user units for tmn...
error: selector 'glibc-locales' matches no derivations
setting up tmpfiles

Also, whenever I open a terminal I get

error: selector 'glibc-locales' matches no derivations

Steps To Reproduce

Run sudo nixos-rebuild switch with my config.

Expected behavior

Locales not broken :)

Additional context

I tried the following to no effect. Also some combination of similar settings, as you can see in my config linked above..

i18n.defaultLocale = "en_US.UTF-8";
i18n.supportedLocales = ["all"];

Removing all packages does not fix the error.

Locale looks like this:

❯ locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME=en_AT.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.126, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.16`
 - channels(tmn): `"nixos-22.05-22.05.1806.e732e1fdbf7"`
 - channels(root): `"nixos-21.11.337967.573603b7fdb"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@gravndal
Copy link
Contributor

gravndal commented Jul 30, 2022

Are you sure that en_AT.UTF-8 exists?

It's not included in glibc as far as I can tell:

 env -i LOCALE_ARCHIVE=(nix eval --raw nixpkgs#glibcLocales)/lib/locale/locale-archive locale -a | rg en_AT
(0|1) 

 env -i LOCALE_ARCHIVE=(nix build --no-link --print-out-paths github:nixos/nixpkgs/nixos-22.05#glibcLocales)/lib/locale/locale-archive locale -a | rg en_AT
(0|1) 

 env -i LOCALE_ARCHIVE=(nix build --no-link --print-out-paths github:nixos/nixpkgs/nixos-21.11#glibcLocales)/lib/locale/locale-archive locale -a | rg en_AT
(0|1) 

As an aside, you don't need to configure LANG in extraLocaleSettings as that's what's set by defining defaultLocale. You also probably do not want en_US without the .UTF-8, as, unless I'm mistaken, that should be the old ISO-8859-1 locale.

Edit: I do see that there are some translations for it in some packages:

(0|1)  nix-locate en_AT
(sparrow.out)                                       873 r /nix/store/55mgc3kgq7vyhcynymfk47s4kin9cgy7-jdk-modules/modules/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_AT.class
snipe-it.out                                        327 r /nix/store/cya4sc5sd8mvfb7vxd7xxj6b36x4ggb8-snipe-it/vendor/nesbot/carbon/src/Carbon/Lang/en_AT.php
python39Packages.nototools.out                    1,150 r /nix/store/n2lkcw8v22nklyg0kwfc62lv7n6zwyrp-python3.9-nototools-0.2.16/lib/python3.9/site-packages/third_party/cldr/common/main/en_AT.xml
python39Packages.nototools.out                    1,150 r /nix/store/n2lkcw8v22nklyg0kwfc62lv7n6zwyrp-python3.9-nototools-0.2.16/third_party/cldr/common/main/en_AT.xml
python39Packages.babel.out                        1,200 r /nix/store/bx5q3mpwrb6ni6v1fg9avfhqiz32kxnw-python3.9-babel-2.10.3/lib/python3.9/site-packages/babel/locale-data/en_AT.dat
python310Packages.nototools.out                   1,150 r /nix/store/za8kiwngcv9ahvp1x6rnw525v6cnk238-python3.10-nototools-0.2.16/lib/python3.10/site-packages/third_party/cldr/common/main/en_AT.xml
python310Packages.nototools.out                   1,150 r /nix/store/za8kiwngcv9ahvp1x6rnw525v6cnk238-python3.10-nototools-0.2.16/third_party/cldr/common/main/en_AT.xml
python310Packages.babel.out                       1,200 r /nix/store/q0qygxabzps0m3bn1jy02jihbwn8pwzi-python3.10-babel-2.10.3/lib/python3.10/site-packages/babel/locale-data/en_AT.dat
perl534Packages.DateTimeLocale.devdoc             3,137 r /nix/store/hh3gqp6id05fxkw0qplbz3bkbmq76n70-perl5.34.1-DateTime-Locale-1.28-devdoc/share/man/man3/DateTime::Locale::en_AT.3.gz
perl534Packages.DateTimeLocale.out               10,861 r /nix/store/2b92xmn7d680h7k3xaab9jhj49fnn3wa-perl5.34.1-DateTime-Locale-1.28/lib/perl5/site_perl/5.34.1/DateTime/Locale/en_AT.pod
perl532Packages.DateTimeLocale.devdoc             3,137 r /nix/store/d33r9m413xsfbrkwfmk9xikgvqp8fcpg-perl5.32.1-DateTime-Locale-1.28-devdoc/share/man/man3/DateTime::Locale::en_AT.3.gz
perl532Packages.DateTimeLocale.out               10,861 r /nix/store/9mk09yzdqsgxsvnc55sdywcbw8y036hq-perl5.32.1-DateTime-Locale-1.28/lib/perl5/site_perl/5.32.1/DateTime/Locale/en_AT.pod
(neovide.out)                                       209 r /nix/store/96xiyq6hzwvqny9lnfs85x00s38g2ydn-source/third_party/externals/icu/source/data/curr/en_AT.txt
(neovide.out)                                       209 r /nix/store/96xiyq6hzwvqny9lnfs85x00s38g2ydn-source/third_party/externals/icu/source/data/lang/en_AT.txt
(neovide.out)                                       569 r /nix/store/96xiyq6hzwvqny9lnfs85x00s38g2ydn-source/third_party/externals/icu/source/data/locales/en_AT.txt
(neovide.out)                                       209 r /nix/store/96xiyq6hzwvqny9lnfs85x00s38g2ydn-source/third_party/externals/icu/source/data/region/en_AT.txt
(neovide.out)                                       209 r /nix/store/96xiyq6hzwvqny9lnfs85x00s38g2ydn-source/third_party/externals/icu/source/data/unit/en_AT.txt
(neovide.out)                                       209 r /nix/store/96xiyq6hzwvqny9lnfs85x00s38g2ydn-source/third_party/externals/icu/source/data/zone/en_AT.txt
ibus-engines.typing-booster-unwrapped.out            535 r /nix/store/whpkhsszwix3818spsl3n3xm5rsvryqz-ibus-typing-booster-2.7.5/share/ibus-typing-booster/data/annotations/en_AT.xml
ibus-engines.typing-booster.out                       0 s /nix/store/rw4aiszwcrkh9y1rzh44gss7x3m3y5r4-ibus-typing-booster-2.7.5-with-hunspell/share/ibus-typing-booster/data/annotations/en_AT.xml
grocy.out                                           327 r /nix/store/3gbg17ah609zhf52lz2k6a3m8bh6r99d-grocy-3.3.0/vendor/nesbot/carbon/src/Carbon/Lang/en_AT.php
(gixy.out)                                        1,200 r /nix/store/d0i0k9bjsmfhpj3fbc9yban1vvzq3jiw-python3.10-babel-2.10.3/lib/python3.10/site-packages/babel/locale-data/en_AT.dat
engelsystem.out                                     326 r /nix/store/qvwwmf3ipmw7hk8vb9y1zqmwnv7islrh-engelsystem-3.1.0/share/engelsystem/vendor/nesbot/carbon/src/Carbon/Lang/en_AT.php
bookstack.out                                       327 r /nix/store/y0yhjklb7y4dhsx6g86zw0iqwp7rwddl-bookstack/vendor/nesbot/carbon/src/Carbon/Lang/en_AT.php

If you want to use those you should configure the LANGUAGE variable.

@tmnvanderberg
Copy link
Author

tmnvanderberg commented Jul 30, 2022

Hey, thanks for your answer.

I don't particularly want to use en_AT, I'm not sure why it is being set. Even when I set LC_TIME to "en_US.UTF-8" in extraLocaleSettings it seems to be set to en_AT.

You're also right about en_US without UTF-8, that was just me trying to cargo-cult my way out of this.

But without this (or for that matter, no locale settings in my config) I still get the selector 'glibc-locales' matches no derivations.

@gravndal
Copy link
Contributor

Have you tried rebooting, or just unsetting LC_TIME in your shell/current running session?

@tmnvanderberg
Copy link
Author

After reboot forcing LC_TIME does work and indeed seems to fix the problem. I guess the en_AT is indeed not working. Thanks a lot!

@tmnvanderberg
Copy link
Author

I was a bit too optimistic - the error is still showing when I nixos-rebuild switch, just not when I open a new terminal ')

@tmnvanderberg tmnvanderberg reopened this Jul 30, 2022
@gravndal
Copy link
Contributor

gravndal commented Jul 30, 2022

If you reduce your locale settings down to just i18n.defaultLocale = "en_US.utf-8";, and then do a nixos-rebuild boot followed by a reboot, does that fix the issue?

Because you're probably currently booted in the old broken configuration, something that you can verify by checking the contents of /etc/locale.conf.

Edit2: /run/booted-system/etc/locale.conf rather.

Edit: or you could try booting the even older, but it should have been working generation? before you tried to change your locale settings and things blew up, and then do a rebuild switch and go from there.

@tmnvanderberg
Copy link
Author

tmnvanderberg commented Jul 30, 2022

Only setting defaultLocale (followed by nixos-rebuild boot and sudo reboot) gives slightly worse results:

❯ locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME=en_AT.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

and a bit more errors when doing a rebuild (after reboot - any commands that invokes perl gives this, I just use nixos-rebuild switch as an example):

 sudo nixos-rebuild switch
[sudo] password for tmn: 
building Nix...
building the system configuration...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
activating the configuration...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
setting up /etc...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
reloading user units for tmn...
error: selector 'glibc-locales' matches no derivations
setting up tmpfiles

I should clarify this was broken before I started changing the locale settings - otherwise I would not have touched them. There is no working generation to fall back to, AFAIK this was broken on my fresh install.

Curiously, locale.conf looks fine (?)

❯ cat /etc/locale.conf 
LANG=en_US.UTF-8

@gravndal
Copy link
Contributor

The warnings don't really matter, they're just perl complaining because LC_TIME is still set to en_AT.UTF-8 in your current session, and should go away as soon as that's not the case.

More importantly, to see exactly what part of the activation script outputs the error, could you try running nixos-rebuild switch with strace?

Though before doing that, it's probably worth seeing if

 grep LOCALE_ARCHIVE /run/current-system/bin/switch-to-configuration
    $ENV{LOCALE_ARCHIVE} = "/nix/store/bykbi1ihjpn0v01lqrlsdpbcsxnpc657-glibc-locales-2.34-210/lib/locale/locale-archive";

Points to something that exists.

@tmnvanderberg
Copy link
Author

This seems to point at something

❯ grep LOCALE_ARCHIVE /run/current-system/bin/switch-to-configuration
    $ENV{LOCALE_ARCHIVE} = "/nix/store/ch13s2s8lndcfgqanr01342x31w02ba7-glibc-locales-2.33-123/lib/locale/locale-archive";

The strace:

sudo strace nixos-rebuild switch
(some stuff omitted..)
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigprocmask(SIG_BLOCK, [INT TERM CHLD], [], 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [INT TERM CHLD], 8) = 0
rt_sigprocmask(SIG_SETMASK, [INT TERM CHLD], NULL, 8) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f358ddc3a10) = 24459
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x446c90, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f358de01c40}, {sa_handler=0x4693d0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f358de01c40}, 8) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 24459
rt_sigaction(SIGINT, {sa_handler=0x4693d0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f358de01c40}, {sa_handler=0x446c90, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f358de01c40}, 8) = 0
ioctl(2, TIOCGWINSZ, {ws_row=76, ws_col=167, ws_xpixel=0, ws_ypixel=0}) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=24459, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
wait4(-1, 0x7ffce1261610, WNOHANG, NULL) = -1 ECHILD (No child processes)
rt_sigreturn({mask=[]})                 = 0
read(255, "\n\n# If we're not just building, "..., 8172) = 592
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigprocmask(SIG_BLOCK, [INT TERM CHLD], [], 8) = 0
lseek(255, -190, SEEK_CUR)              = 17228
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f358ddc3a10) = 24477
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x446c90, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f358de01c40}, {sa_handler=0x4693d0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f358de01c40}, 8) = 0
wait4(-1, perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
activating the configuration...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
setting up /etc...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_TIME = "en_AT.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
reloading user units for tmn...
error: selector 'glibc-locales' matches no derivations

@gravndal
Copy link
Contributor

gravndal commented Jul 30, 2022

Sorry, I should have probably specified with -f as error: selector 'glibc-locales' matches no derivations is probably printed by some child process.

Anyway, if /nix/store/ch13s2s8lndcfgqanr01342x31w02ba7-glibc-locales-2.33-123/lib/locale/locale-archive exists, I don't really see what the issue here could be.

The only thing that comes to mind is that this is caused by something like the activation script doing a systemctl daemon-reload or similar, and that the service manager (or similar) still references the old broken environment from when you booted. But I don't recognise the error message.

If you reboot now, as you noted, your current locale.conf looks good, and so you'd think that things should™ work.

@tmnvanderberg
Copy link
Author

tmnvanderberg commented Jul 30, 2022

https://gist.github.com/tmnvanderberg/f55b51e4ab0cc8bc441e2e7317028eb3

It's quite a dump.

Rebooting doesn't help unfortunately.

@gravndal
Copy link
Contributor

gravndal commented Jul 30, 2022

Yeah, I'm at a bit of a loss...

You can see the error message here: https://github.com/NixOS/nix/blob/17e54a602ef2a767ae3fe5d8789bc4658f439c37/src/nix-env/nix-env.cc#L230

The strace unfortunately doesn't help that much given that the error message isn't captured.

Though that does point to your users service manager as a possible culprit, but we could have also found that by simply having a look at the relevant part of the activation script:

 grep -A5 reloading.user /run/current-system/bin/switch-to-configuration                                                                                                                                                23:45:35
    print STDERR "reloading user units for $name...\n";

    system("/nix/store/6jzkd30lalckhd2p9wj9a595xkq26p92-shadow-4.11.1-su/bin/su", "-s", "/nix/store/lj2bdg618093ny9505d0nzzjdq0fwp8a-bash-5.1-p16/bin/sh", "-l", $name, "-c",
           "export XDG_RUNTIME_DIR=/run/user/$uid; " .
           "$cur_systemd/systemctl --user daemon-reexec; " .
           "$new_systemd/bin/systemctl --user start nixos-activation.service");

Late night edit: you might also want to check that the contents of your nix store isn't in a bad state with something like nix-store --verify --check-contents.

@gravndal
Copy link
Contributor

Notice I overlooked this yesterday.

I should clarify this was broken before I started changing the locale settings - otherwise I would not have touched them. There is no working generation to fall back to, AFAIK this was broken on my fresh install.

If this really was always broken your best bet might be to boot an up to date install medium and run nixos-install again, as your configuration.nix seems fine aside from the—as we've already covered—broken locale settings.

Unless someone with deeper knowledge ends up sweeping in and saving the day that is.

@eddyb
Copy link
Contributor

eddyb commented Aug 14, 2022

(click to open some confused analysis)

Could the errors be related to:

I have two machines with near identical configuration (and no intentional changes in locale config AFAICT).
The one that has no warnings/errors looks like this:

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.59, NixOS, 22.11 (Raccoon), 22.11pre398503.4bdf4169ad2`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.10.3`
 - channels(root): `"nixos"`
 - channels(eddy): `"home-manager"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

$ env | grep -i locale
LOCALE_ARCHIVE_2_27=/nix/store/s3bf05my50y37v88mm6krs1x4s7399rn-glibc-locales-2.35-163/lib/locale/locale-archive
LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive

Note the LOCALE_ARCHIVE_2_27 env var - I don't have that on the machine that's complaining!

The path does seem to be present on both machines, and if I set it the right value, locale starts working.

I have no idea what sets that env var, if I'm going to lose it next time I upgrade, etc.


Nevermind, did more testing, I'm pretty sure I was only affected by this:

It only just so happens that I only have home-manager set up on one of those machines, and that seems to have logic to set LOCALE_ARCHIVE_2_27 to the full locale archive all on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants