From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#25242: Cannot build source derivations with a custom TMPDIR Date: Wed, 21 Dec 2016 10:20:20 +0100 Message-ID: <87r351myej.fsf@gnu.org> References: <20161221082240.GA30326@jasmine> <20161221085421.GA32042@jasmine> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJd57-0000qi-Cb for bug-guix@gnu.org; Wed, 21 Dec 2016 04:21:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJd54-0006ZG-6p for bug-guix@gnu.org; Wed, 21 Dec 2016 04:21:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:34281) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cJd54-0006ZC-3Z for bug-guix@gnu.org; Wed, 21 Dec 2016 04:21:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cJd53-0002tC-TU for bug-guix@gnu.org; Wed, 21 Dec 2016 04:21:01 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20161221085421.GA32042@jasmine> (Leo Famulari's message of "Wed, 21 Dec 2016 03:54:21 -0500") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Leo Famulari Cc: 25242@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Leo Famulari skribis: > On Wed, Dec 21, 2016 at 03:22:40AM -0500, Leo Famulari wrote: >> I ran the guix-daemon with strace, and I see these relevant lines: >>=20 >> 15337 [pid 30675] mkdir("/home/leo/tmp/guix-build/guix-build-nmap-7.40.t= ar.bz2.drv-0", 0700) =3D 0 >> 15338 [pid 30675] getegid() =3D 0 >> 15339 [pid 30675] chown("/home/leo/tmp/guix-build/guix-build-nmap-7.40.t= ar.bz2.drv-0", -1, 0) =3D 0 > > I believe this corresponds to the use of createTempDir() at > nix/libstore/build.cc:1718. The path of the new directory is saved in > the tmpDir variable. > >> 15438 [pid 30693] chdir("/tmp/guix-build-nmap-7.40.tar.bz2.drv-0") =3D -= 1 ENOENT (No such file or directory) > > And then later, at nix/libstore/build.cc:2204, we do this: > > 2204 if (chdir(tmpDirInSandbox.c_str()) =3D=3D -1) > 2205 throw SysError(format("changing into `%1%'") % tmpDir); > > It tries to change to the wrong directory (the new "out of band" > downloader doesn't use a chroot, IIUC), and then prints a misleading > error message. This explains the discrepancy between what we see in > strace and on stderr. Good catch! AFAICS the flaw is that there=E2=80=99s one place where I wrote: if (useChroot && !isBuiltin(drv)) while several other places just do something like: if (useChroot) Could the patch below solve the problem? --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index e823001..38048ce 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -1680,7 +1680,11 @@ void DerivationGoal::startBuilder() % drv.platform % settings.thisSystem % drvPath); } - useChroot = settings.useChroot; + /* Note: built-in builders are *not* running in a chroot environment so + that we can easily implement them in Guile without having it as a + derivation input (they are running under a separate build user, + though). */ + useChroot = settings.useChroot && !isBuiltin(drv); /* Construct the environment passed to the builder. */ env.clear(); @@ -2048,12 +2052,7 @@ void DerivationGoal::runChild() commonChildInit(builderOut); #if CHROOT_ENABLED - /* Note: built-in builders are *not* running in a chroot environment - so that we can easily implement them in Guile without having it as - a derivation input (they are running under a separate build user, - though). */ - - if (useChroot && !isBuiltin(drv)) { + if (useChroot) { /* Initialise the loopback interface. */ AutoCloseFD fd(socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)); if (fd == -1) throw SysError("cannot open IP socket"); --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks! Ludo=E2=80=99. --=-=-=--