GNU bug report logs - #71941
Broken `map-derivation' procedure

Previous Next

Package: guix;

Reported by: Sergio Pastor Pérez <sergio.pastorperez <at> outlook.es>

Date: Thu, 4 Jul 2024 15:06:02 UTC

Severity: normal

To reply to this bug, email your comments to 71941 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#71941; Package guix. (Thu, 04 Jul 2024 15:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sergio Pastor Pérez <sergio.pastorperez <at> outlook.es>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Thu, 04 Jul 2024 15:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sergio Pastor Pérez <sergio.pastorperez <at> outlook.es>
To: bug-guix <at> gnu.org
Subject: Broken `map-derivation' procedure
Date: Thu, 04 Jul 2024 16:59:55 +0200
Hello.

The procedure `map-derivation` from `(guix derivations)` seems broken.

Evaluating this yields an error, it probably shouldn't:
--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> (use-modules (guix)
                                 (guix derivations)
                                 (gnu packages)
                                 (gnu packages perl)
                                 (gnu packages games))
scheme@(guix-user)> (with-store store
                      (let ((cowsay-drv (package-derivation store cowsay))
                            (perl-drv (package-derivation store perl))
                            (perl-5.6-drv (package-derivation store perl-5.6)))
                        (map-derivation store
                                        cowsay-drv
                                        `((,perl-drv . ,perl-5.6-drv)))))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure fport_read: Is a directory

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guix-user) [1]> 
--8<---------------cut here---------------end--------------->8---

If you inspect the `cowsay` derivation, you will see that the mapping
should be possible since it contains the `perl` derivation.

Does anyone have an idea on what could be the issue or how to investigate
further?

Thanks,
Sergio.




Information forwarded to sergio.pastorperez <at> outlook.es, guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, bug-guix <at> gnu.org:
bug#71941; Package guix. (Sun, 01 Sep 2024 16:17:02 GMT) Full text and rfc822 format available.

Message #8 received at 71941 <at> debbugs.gnu.org (full text, mbox):

From: Sergio Pastor Pérez <sergio.pastorperez <at> outlook.es>
To: 71941 <at> debbugs.gnu.org
Cc: Sergio Pastor Pérez <sergio.pastorperez <at> outlook.es>
Subject: [PATCH] guix: fix map-derivation not handling directories
Date: Sun,  1 Sep 2024 18:15:05 +0200
The `map-derivation` procedure was trying to process directories as files.
When a derivation had a 'module import' directory as input, it threw an
exception since it tried to open it as a file.

Change-Id: I9b766f9aaa03ea9307f73e8abb36bc347af4b5e6
---
Hi, as far as I know 'module import' directories don't contain derivation
references, so it should not be needed to apply `substitute-file` on the files of
those directories. This fix just returns the 'module import' directories
untouched. Thoughts?

Note that `map-derivation` is very slow. I could only test it with tiny
derivations, such as the ones provided in the '(gnu packages commencement)'
module.

You can test it with:
--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> (use-modules (guix store)
                                  (guix packages)
                                  (guix derivations)
                                  (gnu packages games)
                                  (gnu packages bootstrap))
scheme@(guix-user)> (with-store store
                      (let ((bootar-drv (package-derivation store (@@ (gnu packages commencement) bootar)))
                            (guile-bootstrap-drv (package-derivation store %bootstrap-guile))
                            (cowsay-drv (package-derivation store cowsay)))
                        (map-derivation store
                                        bootar-drv
                                        `((,guile-bootstrap-drv . ,cowsay-drv)))))
$1 = #<derivation /gnu/store/qwn18yxc1ccdxq1mgg863lfxsfwng3wk-bootar-1b.drv => /gnu/store/852xy3bhck2sd1hq1rmzai0px7fplxfq-bootar-1b 7fcfc3f05b90>
scheme@(guix-user)> (derivation-inputs $1)
$2 = (#<<derivation-input> drv: #<derivation /gnu/store/5rx5dn2xnkjs3q0rzpm66q79ndwrafp7-module-import-compiled.drv => /gnu/store/472plnlfm8yrb3axwy16fydq01idbkv1-module-import-compiled 7fcfc3f05d70> sub-derivations: ("out")> #<<derivation-input> drv: #<derivation /gnu/store/fhqh9f3lmf8wd9mh0bzavpkjnmsb0bg0-cowsay-3.7.0.drv => /gnu/store/vwa9vh21l68ivnwxj18s2gxd1v71w43r-cowsay-3.7.0 7fcfb73a50f0> sub-derivations: ("out")> #<<derivation-input> drv: #<derivation /gnu/store/k6852ja7cvdvbbdxh24ph711gm74m3qq-bootar-1b.ses.drv => /gnu/store/xmw3h03svpw6rwfg03f0m608zkm24qx8-bootar-1b.ses 7fcfc3f05f00> sub-derivations: ("out")>)
--8<---------------cut here---------------end--------------->8---

As you can see, with this fix, the new derivation has the `cowsay` package a an
input.

I would like to encourage people to discuss ways to improve the performance of
this procedure. It would be very useful for system wide package rewriting as
discussed in this thread[1].

[1]: https://lists.gnu.org/archive/html/guix-devel/2024-06/msg00275.html

Regards,
Sergio.


 guix/derivations.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/guix/derivations.scm b/guix/derivations.scm
index a91c1ae984..c16e1c2be3 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -1062,8 +1062,10 @@ (define* (map-derivation store drv mapping
                                     ((_ . replacement)
                                      replacement)
                                     (#f
-                                     (substitute-file source
-                                                      initial replacements))))
+                                     (if (file-is-directory? source)
+                                         source
+                                         (substitute-file source
+                                                          initial replacements)))))
                                 (derivation-sources drv)))
 
              ;; Now augment the lists of initials and replacements.

base-commit: e1c92c98f7afff13fb7060199ba0dd4d9c5c2c53
-- 
2.45.2





This bug report was last modified 46 days ago.

Previous Next


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