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

glibc-locales fails to compile and install on a prefixed nix installation. #15910

Open
vrthra opened this Issue Jun 1, 2016 · 7 comments

Comments

Projects
None yet
5 participants
@vrthra
Member

vrthra commented Jun 1, 2016

Issue description

When using glibc-locales on a prefixed Nix installation, it fails to compile because it tries to write to a non-prefixed location.

Steps to reproduce

bash-4.2$ cat ~/.nixpkgs/config.nix
pkgs:
{
  packageOverrides = self: {
    nixUnstable = self.nixUnstable.override {
       storeDir = "/scratch/gopinatr/nix/store";
       stateDir = "/scratch/gopinatr/nix/var"; };
  };
}

I have the latest master check out at $NIXPKGS. I am trying to install glibc-locales

bash-4.2$ nix-env -i glibc-locales -f $NIXPKGS 
installing ‘glibc-locales-2.23’
these derivations will be built:
  /scratch/gopinatr/nix/store/xw919hgaaqj1mbpfysng92ppnrfnp34p-glibc-locales-2.23.drv
building path(s) ‘/scratch/gopinatr/nix/store/j84kwchcycbsl8yr23g64z51zsdf3c3w-glibc-locales-2.23’
unpacking sources
unpacking source archive /scratch/gopinatr/nix/store/nn100a4p3dnwmmvfwyjv7msxyszfszj8-glibc-2.23.tar.gz
.....
make  -C localedata install-locales
make[2]: Entering directory '/tmp/nix-build-glibc-locales-2.23.drv-0/glibc-2.23/localedata'
.././scripts/mkinstalldirs /scratch/gopinatr/nix/store/j84kwchcycbsl8yr23g64z51zsdf3c3w-glibc-locales-2.23/lib/locale
mkdir -p -- /scratch/gopinatr/nix/store/j84kwchcycbsl8yr23g64z51zsdf3c3w-glibc-locales-2.23/lib/locale
aa_DJ.UTF-8...cannot create temporary file: /tmp/nix-build-glibc-locales-2.23.drv-0/scratch/gopinatr/nix/store/0wfgakp0ssbkr57jdaa23a55s9v6ldf2-glibc-2.23/lib/locale/locale-archive.F3I9sP: No such file or directory
Makefile:205: recipe for target 'install-aa_DJ.UTF-8/UTF-8' failed
make[2]: *** [install-aa_DJ.UTF-8/UTF-8] Error 1
make[2]: Leaving directory '/tmp/nix-build-glibc-locales-2.23.drv-0/glibc-2.23/localedata'
Makefile:421: recipe for target 'localedata/install-locales' failed
make[1]: *** [localedata/install-locales] Error 2
make[1]: Leaving directory '/tmp/nix-build-glibc-locales-2.23.drv-0/glibc-2.23'
Makefile:9: recipe for target 'localedata/install-locales' failed
make: *** [localedata/install-locales] Error 2

builder for ‘/scratch/gopinatr/nix/store/xw919hgaaqj1mbpfysng92ppnrfnp34p-glibc-locales-2.23.drv’ failed with exit code 2
error: build of ‘/scratch/gopinatr/nix/store/xw919hgaaqj1mbpfysng92ppnrfnp34p-glibc-locales-2.23.drv’ failed

That is, it seems to be trying to create /tmp/nix-build-glibc-locales-2.23.drv-0/scratch/gopinatr/nix/store/0wfgakp0ssbkr57jdaa23a55s9v6ldf2-glibc-2.23/lib/locale/locale-archive.F3I9sP, which should not happen because it is disregarding the Nix store directory.

Technical details

  • System: (NixOS: nixos-version, Ubuntu/Fedora: lsb_release -a, ...)
bash-4.2$ cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
  • Nix version: (run nix-env --version)
$ ~/.nix-profile/bin/nix-env --version
nix-env (Nix) 1.12pre4663_1b5b654
  • Nixpkgs version: (run nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion)
bash-4.2$ nix-instantiate -I nixpkgs=$NIXPKGS --eval '<nixpkgs>' -A lib.nixpkgsVersion 
"16.09pre-git"

This was found while trying to check sssd on a prefixed install #14697

@vrthra

This comment has been minimized.

Member

vrthra commented Jun 2, 2016

On further investigation, In file pkgs/development/libraries/glibc/locales.nix the line sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile is the one that is misbehaving. For some reason, the entire NIX store path gets added to $TMPDIR on executing this.

@vrthra

This comment has been minimized.

Member

vrthra commented Jun 2, 2016

For any one else trying to use Nix on a non-prefix installation, this is what is required to get glibc to finish installation, so that one can use sssd which depends up on it. This essentially disables creating of locales-archive.

diff --git a/pkgs/development/libraries/glibc/locales.nix b/pkgs/development/libraries/glibc/locales.nix
index 994390c..a38cd0e 100644
--- a/pkgs/development/libraries/glibc/locales.nix
+++ b/pkgs/development/libraries/glibc/locales.nix
@@ -30,7 +30,7 @@ build null {
       mkdir -p $TMPDIR/"${stdenv.cc.libc.out}/lib/locale"

       # Hack to allow building of the locales (needed since glibc-2.12)
-      sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile
+      sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --no-archive --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile
     ''
       + stdenv.lib.optionalString (!allLocales) ''
       # Check that all locales to be built are supported
@@ -56,13 +56,13 @@ build null {

   installPhase =
     ''
-      mkdir -p "$out/lib/locale"
-      cp -v "$TMPDIR/$NIX_STORE/"*"/lib/locale/locale-archive" "$out/lib/locale"
+      # disabled
     '';

   setupHook = writeText "locales-setup-hook.sh"
     ''
-      export LOCALE_ARCHIVE=@out@/lib/locale/locale-archive
+      # disabled
     '';

   meta.description = "Locale information for the GNU C Library";

Warning: This does not fix the current issue.

@jpotier

This comment has been minimized.

Contributor

jpotier commented Oct 23, 2016

I ran into this today while performing a nixos-install from nix-channel 16.09. Shamelessly changing the file seems to make it continue to the rest of the install process… I have no idea though what I broke.

@Mic92

This comment has been minimized.

Contributor

Mic92 commented Oct 23, 2016

A work around is using the following tool:

https://github.com/lethalman/nix-user-chroot

@jpotier

This comment has been minimized.

Contributor

jpotier commented Oct 23, 2016

Thanks! I've been watching the build going on for a few hours now, so I'll let it finish. I'm hoping I'll be able to re-build glibc-locales once I've booted on my new system. If this fails, then I'll consider your option.

@pjones

This comment has been minimized.

Contributor

pjones commented Mar 20, 2017

I ran into this bug yesterday while trying to nixos-install 16.09 on a new Linode instance.

I was able to work around the issue by cp -r the NixOS channel into /root and patching the locales.nix (thanks @vrthra). (I didn't have sufficient tooling or interest in trying nix-user-chroot. Perhaps that code should be integrated into nixos-install?)

What do you think @lethalman?

@chrisburr

This comment has been minimized.

Contributor

chrisburr commented Sep 4, 2017

I've just ran around this issue and fixed it by editing pkgs/development/libraries/glibc/locales.nix to replace:

mkdir -p $TMPDIR/"${stdenv.cc.libc.out}/lib/locale"`

with

mkdir -p "$(cd "$TMPDIR/glibc-2.25/localedata" && I18NPATH=. GCONV_PATH="$TMPDIR/build/iconvdata" LC_ALL=C localedef --prefix="$TMPDIR" --alias-file=../intl/locale.alias -i locales/aa_DJ -c -f charmaps/UTF-8 aa_DJ.UTF-8 2>&1 | grep -oE "($TMPDIR"'/[^ :]+)')"

The path is

$TMPDIR/$CUSTOM_PREFIX/store/$HASH-glibc-2.25/lib/locale/

But for some reason $HASH from stdenv.cc.libc.out is different that localedef generated the locales in. I was unable to find where $HASH comes from so I just read it from the error message.

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