Subject: Problem building disk-image with guix from git
From: Fredrik Salomonsson <[email-masked]>
To: [email-masked]
Date: Fri, 25 Sep 2020 11:11:30 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi guix,

I thought I would test out the patch from https://issues.guix.info/43366
on my laptop. I cloned the guix repo (checksum: d48b17a), applied the
patch from 43366. Then followed the steps in the manual:
```
$ guix environment guix
$ ./bootstrap
$ ./configure --localstatedir=/var
$ make
```

Then launched the daemon in one shell:
```
$ sudo -E ./pre-inst-env guix-daemon --build-users-group=guixbuild
```

And tried to build the disk image in another
```
$ ./pre-inst-env guix system disk-image --file-system-type=iso9660 gnu/system/install.scm
```

But getting this error:
```
substitute: Backtrace:
substitute: In ice-9/boot-9.scm:
substitute:   3223:13 19 (_)
substitute: In ice-9/threads.scm:
substitute:     390:8 18 (_ _)
substitute: In ice-9/boot-9.scm:
substitute:   3507:20 17 (_)
substitute:    2806:4 16 (save-module-excursion _)
substitute:   3527:26 15 (_)
substitute: In unknown file:
substitute:           14 (primitive-load-path "guix/store" #<procedure 7f12fe96f…>)
substitute: In guix/store.scm:
substitute:      23:0 13 (_)
substitute: In ice-9/boot-9.scm:
substitute:    3380:4 12 (define-module* _ #:filename _ #:pure _ #:version _ # _ …)
substitute:   3393:24 11 (_)
substitute:    222:29 10 (map1 (((guix utils)) ((guix config)) ((guix #)) ((…)) …))
substitute:    222:29  9 (map1 (((guix config)) ((guix deprecation)) ((guix …)) …))
substitute:    222:29  8 (map1 (((guix deprecation)) ((guix memoization)) ((…)) …))
substitute:    222:29  7 (map1 (((guix memoization)) ((guix serialization)) (#) …))
substitute:    222:29  6 (map1 (((guix serialization)) ((guix monads)) ((# #)) …))
substitute:    222:29  5 (map1 (((guix monads)) ((guix records)) ((guix #)) (#) …))
substitute:    222:29  4 (map1 (((guix records)) ((guix base16)) ((guix #)) (#) …))
substitute:    222:29  3 (map1 (((guix base16)) ((guix base32)) ((gcrypt #)) # …))
substitute:    222:29  2 (map1 (((guix base32)) ((gcrypt hash)) ((guix #)) (#) …))
substitute:    222:17  1 (map1 (((gcrypt hash)) ((guix profiling)) ((rnrs #)) # …))
substitute:    3300:6  0 (resolve-interface (gcrypt hash) #:select _ #:hide _ # _ …)
substitute: 
substitute: ice-9/boot-9.scm:3300:6: In procedure resolve-interface:
substitute: no code for module (gcrypt hash)
guix system: error: `/home/plattfot/projects/guix/scripts/guix substitute' died unexpectedly
```

I tried running the guix system command in a guix enviroment:
```
$ guix environment guix --ad-hoc guile guild-gcrypt
```

Same error.

This is what changed when I applied the patch:
```
$ git diff
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 419c10195b..cd43c14eab 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -365,6 +365,16 @@ verbose output to the LOG port."
                         stat
                         lstat)))
 
+(define-syntax-rule (warn-on-error expr file)
+  (catch 'system-error
+    (lambda ()
+      expr)
+    (lambda args
+      (format (current-error-port)
+              "warning: failed to delete ~a: ~a~%"
+              file (strerror
+                    (system-error-errno args))))))
+
 (define* (delete-file-recursively dir
                                   #:key follow-mounts?)
   "Delete DIR recursively, like `rm -rf', without following symlinks.  Don't
@@ -375,10 +385,10 @@ errors."
                         (or follow-mounts?
                             (= dev (stat:dev stat))))
                       (lambda (file stat result)   ; leaf
-                        (delete-file file))
+                        (warn-on-error (delete-file file) file))
                       (const #t)                   ; down
                       (lambda (dir stat result)    ; up
-                        (rmdir dir))
+                        (warn-on-error (rmdir dir) dir))
                       (const #t)                   ; skip
                       (lambda (file stat errno result)
                         (format (current-error-port)
```

Anyone have any pointers what I might have done wrong?

Thanks

-- 
s/Fred[re]+i[ck]+/Fredrik/g