Closed seschwar closed 8 years ago
It might be enough to set LOCALE_ARCHIVE=/usr/lib/locale/locale-archive
. But I know little about issues with nix(pkgs) outside nixos.
@vcunat I believe that's the default even for the Nixpkgs Glibc. But maybe it doesn't exist on Arch.
Relevant ML post, and probably the root cause: https://www.sourceware.org/ml/libc-alpha/2015-08/msg00515.html
> > I have seen several reports of this in Arch Linux when people use locale
> > definition files make with localdef from glibc-2.22 on a system with
> > glibc-2.21.
>
> Not the other way around? glibc 2.22 with locales made with old 2.21
> localedef?
>
We only support localedef from same version of glibc. So both cause problems.
I was trying Nix for the first time today and experienced the same error on Arch Linux. Using LANG=C temporarily works. Also, generating a locale-archive inside the Nix store (/nix/store/la5imi1602jxhpds9675n2n2d0683lbq-glibc-2.20/lib/locale
) using the binaries from the Nix libc and a lightly edited locale-gen
script works although I'm not sure that's the proper way to do it.
Right, @dezgeg, nice reference. This is a general nixpkgs (and nixos) issue then. I don't yet see how to handle this best. It seems clear we might be forced to have multiple locale archives to support running stuff linked against multiple glibc versions. Our glibc already does respond to a versioned variable, but the version wasn't bumped during the last few years ($LOCALE_ARCHIVE_2_11
).
For a fast work-around on non-nixos, you can nix-env -i glibc-locales
(for all locales or a re-configured version of it, the attribute glibcLocales
) and then point $LOCALE_ARCHIVE
to the corresponding lib/locale/locale-archive
location (e.g. the one linked in a profile after installation).
Just ran into this, also on Arch.
Is there any way to fix this on my system or is the nix installer ultimately broken for systems affected?
Ah, I guess it isn't easy to get glibc-locales without having a working nix. To bootstrap this, it should work to download http://lipa.ms.mff.cuni.cz/~cunav5am/nix/locale-archive and point $LOCALE_ARCHIVE
to it.
@vcunat thanks, that helped.
Aside from forcing the use of LANG=C everytime, I couldn't install nix on ArchLinux and get it to work. People who succeeded, what procedure did you follow?
Same. Though my locale
is:
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.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=
+1
While avoiding all locale related errors the following unfortunately no longer works for me:
$ curl https://nixos.org/nix/install | env `locale | sed 's/=.*//; s/^/-u /'` sh
unpacking Nix binary tarball for x86_64-linux from `https://nixos.org/releases/nix/nix-1.10/nix-1.10-x86_64-linux.tar.bz2'...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 67.0M 100 67.0M 0 0 2917k 0 0:00:23 0:00:23 --:--:-- 2953k
performing a single-user installation of Nix...
directory /nix does not exist; creating it by running ‘mkdir -m 0755 /nix && chown seschwar /nix’ using sudo
copying Nix to /nix/store...........................
initialising Nix database...
creating /home/seschwar/.nix-profile
installing ‘nix-1.10’
download-from-binary-cache.pl: could not download ‘https://cache.nixos.org/nix-cache-info’ (Curl error 6)
building path(s) ‘/nix/store/3a8f4srrxamqlz6irbqqzzj4kzijqvif-user-environment’
created 6 symlinks in user environment
/nix/store/na9pnc5pj9d63xn5z8v4wbc35fm4m9y1-nix-1.10/bin/nix-channel: unable to check ‘https://nixos.org/channels/nixpkgs-unstable’
It seems that something about nix-channel
is broken:
$ nix-channel --update
/home/seschwar/.nix-profile/bin/nix-channel: unable to check ‘https://nixos.org/channels/nixpkgs-unstable
’
Is there spurious newline?
If the first step worked then this should allow you to install glibc-locales
:
$ env `locale | sed 's/=.*//; s/^/-u /'` nix-env -i glibc-locales
This is what i have in my ~/.profile
to use nix:
if test -r "${NIX_PROFILE:-$HOME/.nix-profile}/etc/profile.d/nix.sh"; then
. "${NIX_PROFILE:-$HOME/.nix-profile}/etc/profile.d/nix.sh"
elif test -r "${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/etc/profile.d/nix.sh"; then
. "${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/etc/profile.d/nix.sh"
fi
if type nix-env > /dev/null; then
export LOCALE_ARCHIVE=`nix-env --installed --no-name --out-path --query glibc-locales`/lib/locale/locale-archive
fi
This was all with nix 1.9, which still works. However I can neither upgrade to 1.10 nor reinstall it.
I already have two friends whom I had to recommend not using Nix for now because of this -- it seems impossible to get an environment right so that both system apps and Nix (and Nix-compiled ones) work on glibc-2.22
systems. D:
Can we perhaps compile our LOCALE_ARCHIVE
path into our glibc
? This should make it independent off host's glibc
if I understand correctly.
The archive depends on locales that you choose, because it's rather large if you generate all (~100 MB IIRC).
How come it's difficult to get an environment for both Arch and Nix packages? AFAIK $LOCALE_ARCHIVE
and $LOCALE_ARCHIVE_2_11
are nix-specific variables.
@vcunat Strange, they reported it didn't work for them -- maybe we've done something the wrong way. Either way I forgot that it's Nix-specific when we tried to resolve this today -- thanks for reminding!
BTW, why don't we upgrade to glibc-2.22
? I remember you mentioned somewhere that we can't do this precisely because of this bug, but I can't connect the dots...
BTW, why don't we upgrade to glibc-2.22?
When we do, nixos installation will often contain both versions controlled by the same environment variable(s). We will probably have to introduce a new one and (optionally) generate locales for both versions, assuming we want to support mixing the glibc versions (given the nix philosophy).
Understood, thanks for the explanation!
This problem also occurs on Fedora 23.
EDIT: I got it to work! Thanks @vcunat and @wshallum :smile:
@aaronang Could you please elaborate on how you “got it to work”? I face the same issue with Fedora 23. I’ve successfully installed nix using the locale-archive linked by vcunat, then glibc-locales
and set the LOCALE_ARCHIVE
environment variable. Many things do work but I sometimes (e.g., when building numpy
) hit an error like: python2.7: loadlocale.c:130: _nl_intern_locale_data: Assertion
cnt < (sizeof (_nl_value_type_LC_COLLATE) / sizeof (_nl_value_type_LC_COLLATE[0]))'` Thanks.
For building problems, I suppose it's best to setup chrooted builds to avoid picking up Fedora's files.
chrooted build, obviously. That fixed it. Thanks a lot.
I've run into this when attempting to install Nix on Fedora 23 as well. @vbgl , could you elaborate on what you did to solve this?
From what I recall, the following lead to a (mostly) working install of nix on Fedora23:
a) Download vcunat’s locale-archive
from: http://lipa.ms.mff.cuni.cz/~cunav5am/nix/locale-archive (see comment above).
b) export LOCALE_ARCHIVE=/path/to/locale-archive
c) install nix
d) using nix, install nixpkgs.glibcLocales
and update your LOCALE_ARCHIVE
environment variable (e.g., export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive
; see seschwar’s comment above)
e) if you plan to build things locally (rather than always fetching from binary caches), enable chrooted builds. Here’s the contents of my /etc/nix/nix.conf
:
build-users-group = nixbld
auto-optimise-store = true
build-use-chroot = true
build-chroot-dirs = /bin/sh=/nix/store/xag5ayq906w9zhlxs8wayv4kvpiyqphq-bash-4.3-p42/bin/sh
That being said, this is not perfect: pure shells (nix-shell --pure
) do not work, as the LOCALE_ARCHIVE
environment variable is not propagated from the parent shell to the nix shell.
@vbgl That worked beautifully. Thank you kindly for the detailed instructions.
The problem can occur on Gentoo Linux too. Summarizing the workaround: (once) env -u LANG -u LC_MESSAGES -u LC_TIME -u LC_NUMERIC nix-env -iA nixpkgs.glibcLocales (in shell init) export LOCALE_ARCHIVE=$HOME/.nix-profile/lib/locale/locale-archive
BTW the glibc in current/recent nixpkgs-unstable now have patches to avoid the loadlocale.c:130: _nl_intern_locale_data: Assertion 'cnt < (sizeof (_nl_value_type_LC_COLLATE) / sizeof (_nl_value_type_LC_COLLATE[0]))' failed.
assert from happening, making this slightly less of a problem.
@dezgeg so is this fixed?
At least it doesn't crash. I think you can still get the annoying locale warnings from perl (like in https://github.com/NixOS/nixpkgs/issues/8398). So probably this one can be closed.
After an upgrade from 18.03 to 18.09 of NixOS I see the same issue.
vim
crashed with the message, as do htop
and screen
.
tmux
works.
locale outputs "en_US.UTF-8"
for all values except for LC_ALL (which is empty) and LANG (which is set to that value without the double quotes).
I am not very amused right now. Is "can we start vim?" part of a release channel test?
Ditto, mosh
refuses to connect to any hosts, because en_US.UTF8 apparently is no longer a UTF-8 locale.
Do we not have tests for running Nix on top of non-NixOS?
This fixed a similar issue for me: https://nixos.wiki/wiki/Locales
Can anyone please update the dead link in https://github.com/NixOS/nix/issues/599#issuecomment-153885553 ?
@vcunat maybe?
I've tried following the link posted in https://github.com/NixOS/nix/issues/599#issuecomment-1218133981 by @Geometer1729 but on Alpine Linux the path /usr/lib/locale/locale-archive
does not exist for example. Hence I'd like to download the locale-archive separately, and then place it there myself.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
I just tried installing Nix for the first time ever. I have my locale configured are as follows:
Trying to install Nix under Arch Linux as follows fails:
Rerunning the installer with my locale variables unset succeeds, after having cleaned up the previous failed install (
sudo rm -fr /nix
):The same thing happens when I'm trying to install a package:
How am I supposed to set up my locale so that it doesn't break Nix? Would I have to call
localedef
in eachglibc
package? But weren't these supposed to be read only?And shouldn't the installer take care of all that? Producing a broken installation is not very helpful. :wink: