unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / Atom feed
* bug#50441: Wrong build directory number shown in environment-variables file
@ 2021-09-06 21:22 Christine Lemmer-Webber
  2021-09-07  4:34 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
  2021-09-07  4:44 ` Sarah Morgensen
  0 siblings, 2 replies; 6+ messages in thread
From: Christine Lemmer-Webber @ 2021-09-06 21:22 UTC (permalink / raw)
  To: 50441

I was doing guix build with "--keep-missing" and looking around in a few
of the output directories.  I was peeking in:

  /tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-4

But wait... the "environment-variables" file says:

#+BEGIN_SRC sh
export TEMP=\
"/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
export TEMPDIR=\
"/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
export TMP=\
"/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
export TMPDIR=\
"/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
#+END_SRC

Now wait a minute.  Look at that last number.  What the hell is going on
here?  Is this a bug in Guix?  Why is it pointing at -0 in the -4 build
directory?

Does this point at a more serious issue?  What's going on?




^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#50441: Wrong build directory number shown in environment-variables file
  2021-09-06 21:22 bug#50441: Wrong build directory number shown in environment-variables file Christine Lemmer-Webber
@ 2021-09-07  4:34 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
  2021-09-07 14:26   ` Christine Lemmer-Webber
  2021-09-07  4:44 ` Sarah Morgensen
  1 sibling, 1 reply; 6+ messages in thread
From: Tobias Geerinckx-Rice via Bug reports for GNU Guix @ 2021-09-07  4:34 UTC (permalink / raw)
  To: Christine Lemmer-Webber; +Cc: 50441

[-- Attachment #1: Type: text/plain, Size: 598 bytes --]

Christine,

Christine Lemmer-Webber 写道:
> I was doing guix build with "--keep-missing" and looking around 
> in a few
> of the output directories.  I was peeking in:
>
>   /tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-4
>
> But wait... the "environment-variables" file says:
>
> #+BEGIN_SRC sh
> export TEMP=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"

Part of the build environment isolation/reproducibility is that 
processes inside it always see a build directory ending in ‘-0’, 
regardless of the file name on the host system.

Kind regards,

T G-R

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#50441: Wrong build directory number shown in environment-variables file
  2021-09-06 21:22 bug#50441: Wrong build directory number shown in environment-variables file Christine Lemmer-Webber
  2021-09-07  4:34 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
@ 2021-09-07  4:44 ` Sarah Morgensen
  2021-09-07 14:25   ` Christine Lemmer-Webber
  1 sibling, 1 reply; 6+ messages in thread
From: Sarah Morgensen @ 2021-09-07  4:44 UTC (permalink / raw)
  To: Christine Lemmer-Webber; +Cc: 50441

Hello Christine,

Christine Lemmer-Webber <cwebber@dustycloud.org> writes:

> I was doing guix build with "--keep-missing" and looking around in a few
> of the output directories.  I was peeking in:
>
>   /tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-4
>
> But wait... the "environment-variables" file says:
>
> #+BEGIN_SRC sh
> export TEMP=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
> export TEMPDIR=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
> export TMP=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
> export TMPDIR=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
> #+END_SRC
>
> Now wait a minute.  Look at that last number.  What the hell is going on
> here?  Is this a bug in Guix?  Why is it pointing at -0 in the -4 build
> directory?
>
> Does this point at a more serious issue?  What's going on?

I've definitely noticed this before as well, and had to work around it
(I needed to inspect temp caches).  Thanks for actually sending a bug
report :)

I'm not at all familiar with the nix code, but it looks like this might
be related:

nix/libstore/build.cc:1654
--8<---------------cut here---------------start------------->8---
    /* In a sandbox, for determinism, always use the same temporary
       directory. */
    tmpDirInSandbox = useChroot ? canonPath("/tmp", true) + "/guix-build-" + drvName + "-0" : tmpDir;

    /* For convenience, set an environment pointing to the top build
       directory. */
    env["NIX_BUILD_TOP"] = tmpDirInSandbox;

    /* Also set TMPDIR and variants to point to this directory. */
    env["TMPDIR"] = env["TEMPDIR"] = env["TMP"] = env["TEMP"] = tmpDirInSandbox;

    /* Explicitly set PWD to prevent problems with chroot builds.  In
       particular, dietlibc cannot figure out the cwd because the
       inode of the current directory doesn't appear in .. (because
       getdents returns the inode of the mount point). */
    env["PWD"] = tmpDirInSandbox;
--8<---------------cut here---------------end--------------->8---

I'm not entirely sure what's going on.  I think we build in chroot by
default, which would explain why the temp vars get set to "-0" even
though everything else seems to work okay.

--
Sarah




^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#50441: Wrong build directory number shown in environment-variables file
  2021-09-07  4:44 ` Sarah Morgensen
@ 2021-09-07 14:25   ` Christine Lemmer-Webber
  0 siblings, 0 replies; 6+ messages in thread
From: Christine Lemmer-Webber @ 2021-09-07 14:25 UTC (permalink / raw)
  To: Sarah Morgensen; +Cc: 50441

Loops like Tobias gave the explanation in their reply:

> Part of the build environment isolation/reproducibility is that
> processes inside it always see a build directory ending in ‘-0’, 
> regardless of the file name on the host system.

Sarah Morgensen <iskarian@mgsn.dev> writes:

> Hello Christine,
>
> Christine Lemmer-Webber <cwebber@dustycloud.org> writes:
>
>> I was doing guix build with "--keep-missing" and looking around in a few
>> of the output directories.  I was peeking in:
>>
>>   /tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-4
>>
>> But wait... the "environment-variables" file says:
>>
>> #+BEGIN_SRC sh
>> export TEMP=\
>> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
>> export TEMPDIR=\
>> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
>> export TMP=\
>> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
>> export TMPDIR=\
>> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
>> #+END_SRC
>>
>> Now wait a minute.  Look at that last number.  What the hell is going on
>> here?  Is this a bug in Guix?  Why is it pointing at -0 in the -4 build
>> directory?
>>
>> Does this point at a more serious issue?  What's going on?
>
> I've definitely noticed this before as well, and had to work around it
> (I needed to inspect temp caches).  Thanks for actually sending a bug
> report :)
>
> I'm not at all familiar with the nix code, but it looks like this might
> be related:
>
> nix/libstore/build.cc:1654
>
>     /* In a sandbox, for determinism, always use the same temporary
>        directory. */
>     tmpDirInSandbox = useChroot ? canonPath("/tmp", true) + "/guix-build-" + drvName + "-0" : tmpDir;
>
>     /* For convenience, set an environment pointing to the top build
>        directory. */
>     env["NIX_BUILD_TOP"] = tmpDirInSandbox;
>
>     /* Also set TMPDIR and variants to point to this directory. */
>     env["TMPDIR"] = env["TEMPDIR"] = env["TMP"] = env["TEMP"] = tmpDirInSandbox;
>
>     /* Explicitly set PWD to prevent problems with chroot builds.  In
>        particular, dietlibc cannot figure out the cwd because the
>        inode of the current directory doesn't appear in .. (because
>        getdents returns the inode of the mount point). */
>     env["PWD"] = tmpDirInSandbox;
>
> I'm not entirely sure what's going on.  I think we build in chroot by
> default, which would explain why the temp vars get set to "-0" even
> though everything else seems to work okay.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#50441: Wrong build directory number shown in environment-variables file
  2021-09-07  4:34 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
@ 2021-09-07 14:26   ` Christine Lemmer-Webber
  2021-09-14  7:47     ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Christine Lemmer-Webber @ 2021-09-07 14:26 UTC (permalink / raw)
  To: Tobias Geerinckx-Rice; +Cc: 50441

Hi Tobias!

Tobias Geerinckx-Rice <me@tobias.gr> writes:

> [[PGP Signed Part:Undecided]]
> Christine,
>
> Christine Lemmer-Webber 写道:
>> I was doing guix build with "--keep-missing" and looking around in a
>> few
>> of the output directories.  I was peeking in:
>>
>>   /tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-4
>>
>> But wait... the "environment-variables" file says:
>>
>> #+BEGIN_SRC sh
>> export TEMP=\
>> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
>
> Part of the build environment isolation/reproducibility is that
> processes inside it always see a build directory ending in ‘-0’, 
> regardless of the file name on the host system.
>
> Kind regards,
>
> T G-R
>
> [[End of PGP Signed Part]]

This makes sense in general, though I wonder if when using --keep-failed
if environment-variables should dump out something different, since
that file is around for debugging, and sourcing it might set up the
wrong paths I guess?  What do you think?




^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#50441: Wrong build directory number shown in environment-variables file
  2021-09-07 14:26   ` Christine Lemmer-Webber
@ 2021-09-14  7:47     ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2021-09-14  7:47 UTC (permalink / raw)
  To: Christine Lemmer-Webber; +Cc: 50441

Hi,

Christine Lemmer-Webber <cwebber@dustycloud.org> skribis:

> Tobias Geerinckx-Rice <me@tobias.gr> writes:

[...]

>>> #+BEGIN_SRC sh
>>> export TEMP=\
>>> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
>>
>> Part of the build environment isolation/reproducibility is that
>> processes inside it always see a build directory ending in ‘-0’, 
>> regardless of the file name on the host system.
>>
>> Kind regards,
>>
>> T G-R
>>
>> [[End of PGP Signed Part]]
>
> This makes sense in general, though I wonder if when using --keep-failed
> if environment-variables should dump out something different, since
> that file is around for debugging, and sourcing it might set up the
> wrong paths I guess?  What do you think?

There’s no good solution I’m afraid.  Directory names within the build
environment must be fixed to ensure reproducibility, as Tobias writes;
yet, the daemon shouldn’t overwrite directories that happen to already
exist in the “real” /tmp.

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-14  7:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 21:22 bug#50441: Wrong build directory number shown in environment-variables file Christine Lemmer-Webber
2021-09-07  4:34 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
2021-09-07 14:26   ` Christine Lemmer-Webber
2021-09-14  7:47     ` Ludovic Courtès
2021-09-07  4:44 ` Sarah Morgensen
2021-09-07 14:25   ` Christine Lemmer-Webber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).