Cyril Roelandt <tipec...@gmail.com> skribis: > On 03/07/2014 10:40 AM, Ludovic Courtès wrote: >> Cyril Roelandt <tipec...@gmail.com> skribis:
[...] >>> +--- Lib/test/test_posixpath.py 2014-03-01 05:46:56.984311000 +0100 >>> ++++ Lib/test/test_posixpath.py 2014-03-01 06:20:50.704311000 +0100 >>> +@@ -319,7 +319,11 @@ >>> + del env['HOME'] >>> + home = pwd.getpwuid(os.getuid()).pw_dir >>> + # $HOME can end with a trailing /, so strip it (see >>> #17809) >>> +- self.assertEqual(posixpath.expanduser("~"), >>> home.rstrip("/")) >>> ++ # The Guix builders have '/' as a home directory, so >>> ++ # home.rstrip("/") will be an empty string and the test will >>> ++ # fail. Let's just disable it since it does not really make >>> ++ # sense with such a bizarre setup. >>> ++ # self.assertEqual(posixpath.expanduser("~"), >>> home.rstrip("/")) >> >> I see that the recipe’s ‘pre-check’ phase does: >> >> (setenv "HOME" (getcwd)) >> >> so $HOME should actually be /tmp/nix-build-xxx, not just /, no? >> > > Yes, but I think it uses getpwent() or something that does not use > $HOME to retrieve the home directory in this case. Here’s what I see, with nscd turned off (this uses getpwnam(2)): --8<---------------cut here---------------start------------->8--- $ strace guile -c '(getpw "ludo")' [...] open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 5 fstat(5, {st_mode=S_IFREG|0644, st_size=2072, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f264dea5000 read(5, "root:x:0:0:System administrator:"..., 4096) = 2072 --8<---------------cut here---------------end--------------->8--- Normally the chroot environment has all that too. And indeed, the equivalent of the above Python snippet seems to work: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(guix) scheme@(guile-user)> ,use(guix monads) scheme@(guile-user)> (define s (open-connection)) scheme@(guile-user)> (derivation-expression "getpw" '(pk (getpw (getuid)))) $11 = #<procedure 3da30f0 at guix/monads.scm:297:6 (store)> scheme@(guile-user)> (run-with-store s $11) $12 = #<derivation /gnu/store/bhmd5bg9s64an3s8ssmwx6l90dkr56hx-getpw.drv => /gnu/store/z68rzri3myxx1dg931fb1ksxdg7c29zg-getpw 33dfa00> scheme@(guile-user)> (build-derivations s (list $12)) building path(s) `/gnu/store/z68rzri3myxx1dg931fb1ksxdg7c29zg-getpw' ;;; (#("nixbld" "x" 30001 30000 "Nix build user" "/" "/noshell")) builder for `/gnu/store/bhmd5bg9s64an3s8ssmwx6l90dkr56hx-getpw.drv' failed to produce output path `/gnu/store/z68rzri3myxx1dg931fb1ksxdg7c29zg-getpw' --8<---------------cut here---------------end--------------->8--- Libguile implements this using getpwuid(3). I wonder if CPython is doing something else. Thanks, Ludo’.