You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies if this has already been covered or is expected, I've searched through a lot of issues but I'm not familiar enough with how glibc locales are supposed to work to know for sure.
Issue description
setlocale() only supports trivial locales (e.g. C). Calling setlocale() with e.g. LC_ALL=en_AU.UTF-8 fails (returns null). I discovered this because after an upgrade, fish shell no longer thinks my locale supports UTF-8: fish-shell/fish-shell#4935
Steps to reproduce
First, the setup:
$ cat setlocale.c
#include <locale.h>
#include <stdio.h>
int main() {
char* locale = setlocale(LC_ALL, "");
printf("locale = %s\n", locale);
}
$ cat setlocale.nix
with (import <nixpkgs> {});
stdenv.mkDerivation {
name = "setlocale-0";
buildCommand = ''
gcc -o $out ${./setlocale.c}
'';
}
# build one with system libraries:
$ gcc -o setlocale setlocale.c
# and one with nix:
$ nix-build setlocale.nix
/nix/store/gc3s42m3j2jhvxqp73xp5bhdqfrckfah-setlocale-0
Doing an strace, I found that the nix version is trying to open two locale files:
$ strace -eopenat -f ./result 2>&1 | grep locale-archive
openat(AT_FDCWD, "/nix/store/27x7pinqdsl9f3rpbm8bsszd9fhwq266-glibc-2.27/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
I'm guessing that my /usr/lib/locale/locale-archive is an old / incompatible version, since an strace confirms that file is opened by the (successful) ./setlocale
Is it possible for libc to use this file by default? If not, is there anything I can put in my ~/.nixpkgs/config.nix to do this globally (ideally without causing mass rebuilds...)?
thanks - definitely sounds familiar, although that seems to be nixos focussed, while this is an issue with plain nixpkgs (where it's likely systems will be running with an incompatible locale-archive for a long time)
Apologies if this has already been covered or is expected, I've searched through a lot of issues but I'm not familiar enough with how glibc locales are supposed to work to know for sure.
Issue description
setlocale()
only supports trivial locales (e.g.C
). Callingsetlocale()
with e.g.LC_ALL=en_AU.UTF-8
fails (returns null). I discovered this because after an upgrade,fish
shell no longer thinks my locale supports UTF-8: fish-shell/fish-shell#4935Steps to reproduce
First, the setup:
Now, to run them:
Doing an
strace
, I found that the nix version is trying to open two locale files:I'm guessing that my
/usr/lib/locale/locale-archive
is an old / incompatible version, since anstrace
confirms that file is opened by the (successful)./setlocale
LDD info:
My system libc is 2.26, while nixpkgs is 2.27.
If I explicitly provide nix's libc locale archive, it works:
Is it possible for libc to use this file by default? If not, is there anything I can put in my
~/.nixpkgs/config.nix
to do this globally (ideally without causing mass rebuilds...)?Technical details
The text was updated successfully, but these errors were encountered: