Nixpkgs: Why do these errors differ in nix-env and nix-shell?

Created on 12 Mar 2015  Â·  11Comments  Â·  Source: NixOS/nixpkgs

When I try to run installPhase in nix-shell --pure I get:

[nix-shell:~/tmp/cups-filters-1.0.61]$ installPhase 
install flags: install SHELL=/nix/store/c8phpzx00hrfpbjwih1czsag0zgxrs51-bash-4.3-p33/bin/bash SHELL=/nix/store/c8phpzx00hrfpbjwih1czsag0zgxrs51-bash-4.3-p33/bin/bash CUPS_SERVERBIN=$(out)/lib/cups CUPS_DATADIR=$(out)/share/cups CUPS_SERVERROOT=$(out)/etc/cups   gsettingsschemadir=/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/share/gsettings-schemas/cups-filters-1.0.61/glib-2.0/schemas/
make[1]: Entering directory `/run/user/1000/tmpdir/cups-filters-1.0.61'
 /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/mkdir -p '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib'
 /nix/store/c8phpzx00hrfpbjwih1czsag0zgxrs51-bash-4.3-p33/bin/bash ./libtool   --mode=install /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install -c   libcupsfilters.la libfontembed.la '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib'
libtool: install: /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install -c .libs/libcupsfilters.so.1.0.0 /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib/libcupsfilters.so.1.0.0
/nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install: cannot remove '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib/libcupsfilters.so.1.0.0': Permission denied
make[1]: *** [install-libLTLIBRARIES] Error 1
make[1]: Leaving directory `/run/user/1000/tmpdir/cups-filters-1.0.61'
make: *** [install-am] Error 2
cat: /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib/cups/filter/pstopdf: No such file or directory
bash: /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib/cups/filter/pstopdf: No such file or directory
cat: /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib/cups/filter/texttops: No such file or directory
bash: /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib/cups/filter/texttops: No such file or directory
cat: /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib/cups/filter/imagetops: No such file or directory
bash: /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib/cups/filter/imagetops: No such file or directory

That’s because the line that does installaion reads:

$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)";

while $DESTDIR is empty and

libdir='${exec_prefix}/lib'
exec_prefix='${prefix}'
prefix='/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61'

On the other hand, if I install with nix-env the error is different:

building install-binPROGRAMS
 /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/mkdir -p '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/bin'
  /nix/store/c8phpzx00hrfpbjwih1czsag0zgxrs51-bash-4.3-p33/bin/bash ./libtool   --mode=install /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install -c ttfread '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/bin'
libtool: install: /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install -c .libs/ttfread /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/bin/ttfread
building install-sbinPROGRAMS
 /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/mkdir -p '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/sbin'
  /nix/store/c8phpzx00hrfpbjwih1czsag0zgxrs51-bash-4.3-p33/bin/bash ./libtool   --mode=install /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install -c cups-browsed '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/sbin'
libtool: install: /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install -c cups-browsed /nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/sbin/cups-browsed
building install-docDATA
 /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/mkdir -p '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/share/doc/cups-filters'
 /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install -c -m 644 AUTHORS COPYING NEWS INSTALL README '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/share/doc/cups-filters'
building install-initrcSCRIPTS
 /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/mkdir -p '/etc/init.d'
 /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install -c utils/cups-browsed '/etc/init.d'
/nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/install: cannot remove '/etc/init.d/cups-browsed': Permission denied
make[1]: *** [install-initrcSCRIPTS] Error 1
make[1]: Leaving directory `/tmp/nix-build-cups-filters-1.0.61.drv-0/cups-filters-1.0.61'
make: *** [install-am] Error 2
builder for ‘/nix/store/qd5cpjj0ka21v4nkydmwsdac6c0h93j0-cups-filters-1.0.61.drv’ failed with exit code 2

Does anyone have an idea why the errors are different? Does anyone have an idea what to do? I suppose this doesn’t happen on NixOS, so Hydra builds the expression successfully.

question

Most helpful comment

I've created Q in SO
http://stackoverflow.com/questions/31559303/nix-shell-error-mkdir-cannot-create-directory-nix-store-read-only-fil

differences between nix-env and nix-shell are so bad for newcomers...

All 11 comments

By the way, if I first collect garbage and then run installPhase in nix-shell, I get:

make[1]: Entering directory `/run/user/1000/tmpdir/cups-filters-1.0.61'
 /nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/mkdir -p '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61/lib'
/nix/store/rgmby7y1kyxac8r7d7c50q2w7hxms3b2-coreutils-8.23/bin/mkdir: cannot create directory '/nix/store/x82fh6dc3ybh4xzfizvkdg6w15wknfcm-cups-filters-1.0.61': Permission denied

So, I guess there is an issue and a question. The issue is that the expression is broken on non-NixOS, and the question is why do the errors in nix-env and nix-shell differ.

I worked around the issue in #6770, but the question remains…

The first error in nix-shell is because you cannot install anything, as you don't have permission to mutate the nix store. You can't installPhase from within nix-shell with a nix-daemon setup, because the store is owned by root.

The second error is because it doesn't hit the error of nix-shell, it can mutate the nix store so it goes forward. Then it wants to mutate something in /etc but has no permission to do so.

The first error in nix-shell is because you cannot install anything, as you don't have permission to mutate the nix store.

Oh, it’s just that? Huh, I’m pretty dumb… never had to test the installation phase in nix-shell =).

It would be nice to have nix-shell … well, I don’t know… detach the namespace and maybe mount an empty directory over $out to make it possible to test the installation phase…

@kirelagin you still have to create an empty dir in the nix store, and you can't as user. Too bad the filesystem itself is not unsharable :P

Btw you can test the install phase by setting a temp $out variable.

@lethalman Right, then one has to mount aufs (or overlayfs or whatever) over the store first to create the empty dir.

@kirelagin or just a userHook in config.nix by setting $out to a temp dir :)

@lethalman That’s also a nice idea.

I've created Q in SO
http://stackoverflow.com/questions/31559303/nix-shell-error-mkdir-cannot-create-directory-nix-store-read-only-fil

differences between nix-env and nix-shell are so bad for newcomers...

Two solutions:

  • Don't create $out in configurePhase, do it in installPhase instead.
  • Set $out to some different value.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ayyess picture ayyess  Â·  3Comments

ghost picture ghost  Â·  3Comments

retrry picture retrry  Â·  3Comments

yawnt picture yawnt  Â·  3Comments

lverns picture lverns  Â·  3Comments