From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#35387: unpack phase in the gnu-build-system is sometimes non-deterministic Date: Tue, 23 Apr 2019 16:36:40 +0200 Message-ID: <87ef5shjpj.fsf@gnu.org> References: <87mukh6vjq.fsf@cbaines.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:47460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIwXf-0004XE-Ef for bug-guix@gnu.org; Tue, 23 Apr 2019 10:37:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIwXe-0005g5-EX for bug-guix@gnu.org; Tue, 23 Apr 2019 10:37:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40431) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIwXe-0005fw-BA for bug-guix@gnu.org; Tue, 23 Apr 2019 10:37:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIwXe-0000mb-8E for bug-guix@gnu.org; Tue, 23 Apr 2019 10:37:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87mukh6vjq.fsf@cbaines.net> (Christopher Baines's message of "Tue, 23 Apr 2019 08:16:25 +0100") 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: Christopher Baines Cc: 35387@debbugs.gnu.org Hi Chris, Christopher Baines skribis: > I believe that the direnv package has encountered an issue with the > gnu-build-system [1]. > > 1: https://issues.guix.info/issue/35386 > > Due to the combination of the 'setup-go-environment phase from the > go-build-system, and the 'unpack phase of the gnu-build-system, there > are two directories to be considered by first-subdirectory when called > from the unpack phase. > > It seems from direnv that this either consistently, with the package > working on one machine, or failing consistently on another. > > To avoid issues like this in the future, I think it would be good to > have first-subdirectory raise an error if it's behaviour could be > non-deterministic. =E2=80=98file-system-fold=E2=80=99 is just a wrapper around =E2=80=98readdi= r=E2=80=99 so the order in which it sees directory entries is non-deterministic. What about writing it like this: (define (first-subdirectory directory) "Return the file name of the first sub-directory of DIRECTORY." (match (scandir directory (lambda (file) (and (not (member file '("." ".."))) (file-is-directory? (string-append directory "/" file))))) ((first . _) first))) The result will be deterministic since =E2=80=98scandir=E2=80=99 sorts entr= ies. Thanks, Ludo=E2=80=99.