GNU bug report logs - #64858
~guix shell -C -f guix.scm …~ should not always need ~--rebuild-cache~ option to build the expected environment.

Previous Next

Package: guix;

Reported by: Pierre-Henry Fröhring <phfrohring <at> deeplinks.com>

Date: Tue, 25 Jul 2023 16:40:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Felix Lechner <felix.lechner <at> lease-up.com>
To: 64858 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>, Felix Lechner <felix.lechner <at> lease-up.com>, Pierre-Henry Fröhring <phfrohring <at> deeplinks.com>
Subject: bug#64858: [PATCH] In 'guix shell', discard ad-hoc profile when 'guix.scm' file is newer. (Closes: #64858)
Date: Sun, 19 Nov 2023 21:12:36 -0800
Fixes a bug that prevents rebuilds for folks who use 'guix shell' repeatedly
to refine a package declaration located in a 'guix.scm' file.

The mtime of 'guix.scm' is never evaluated because 'file' is #f here and the
code path taken always returns 0 as the purported mtime.

  https://github.com/guix-mirror/guix/blob/71b92466430acb8c91841522dc0eb7d766af4388/guix/scripts/shell.scm#L390

In the consuming code, the 'timestamp' is always less than the mtime of the
profile in the multi-line AND-ed conditional here:

  https://github.com/guix-mirror/guix/blob/71b92466430acb8c91841522dc0eb7d766af4388/guix/scripts/shell.scm#L250

As a result, outdated ad-hoc profiles are always reused unless they are
expressly deleted via:

  rm ~/.cache/guix/profiles/*

The bug was potentially introduced in commit c42b7baf when 'package was
transformed to 'ad-hoc-package without also changing the line in this commit.

A minimal reproducer can be found here:

  https://codeberg.org/lechner/shell-bug
---

Hi Ludo'

> ‘guix shell’ caches based on the mtime of ‘guix.scm’

That's how is should work, but it doesn't as explained above. Here is
a patch.

Please adjust the commit message to your liking. Thanks!

Kind regards
Felix

 guix/scripts/shell.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm
index 10ea110fee..d29367c8ee 100644
--- a/guix/scripts/shell.scm
+++ b/guix/scripts/shell.scm
@@ -398,7 +398,7 @@ (define (key->file key)
            (values #f #f)))
       ((('nesting? . #t) . rest)
        (loop rest system file (append specs '("nested guix"))))
-      ((('load . ('package candidate)) . rest)
+      ((('load . ('ad-hoc-package candidate)) . rest)
        (if (and (not file) (null? specs))
            (loop rest system candidate specs)
            (values #f #f)))

base-commit: 71b92466430acb8c91841522dc0eb7d766af4388
-- 
2.41.0





This bug report was last modified 1 year and 179 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.