bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#69836: Guix build builds but errors when given file-like object


From: Richard Sent
Subject: bug#69836: Guix build builds but errors when given file-like object
Date: Sat, 16 Mar 2024 22:48:02 -0400

When running ~$ guix build -f test.scm~, where test.scm returns a file
like object, the output is built but an error is printed. According to
(info (guix) Additional Build Options), file-like objects are supported
by guix build -f.

For example, with the following file:

--8<---------------cut here---------------start------------->8---
(use-modules
 (guix gexp))

(plain-file "hello-world" "HELLO WORLD")
--8<---------------cut here---------------end--------------->8---

/gnu/store/.....-hello-world is built and contains "HELLO WORLD", but
there is an match error in guix/ui.scm:show-derivation-outputs.

--8<---------------cut here---------------start------------->8---
...
In guix/scripts/build.scm:
   804:26  4 (_)
In srfi/srfi-1.scm:
    634:9  3 (for-each #<procedure show-derivation-outputs (derivat?> ?)
In guix/ui.scm:
    956:2  2 (show-derivation-outputs _)
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" 
"/gnu/store/wvr6byljawdlxgxabl6798i0afqgpyiq-hello-world")'.
--8<---------------cut here---------------end--------------->8---

This error could be fixed with the following patch:

--8<---------------cut here---------------start------------->8---
diff --git a/guix/ui.scm b/guix/ui.scm
index 962d291d2e..4dc926cbfe 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -958,7 +958,9 @@ (define (show-derivation-outputs derivation)
      (show-outputs derivation (derivation-output-names derivation)))
     ((? derivation-input? input)
      (show-outputs (derivation-input-derivation input)
-                   (derivation-input-sub-derivations input)))))
+                   (derivation-input-sub-derivations input)))
+    ((? string?) ;file-like object was built
+     (format #t "~a~%" derivation))))
 
 (define* (check-available-space need
                                 #:optional (directory (%store-prefix)))
--8<---------------cut here---------------end--------------->8---

However, this brings up another error.

--8<---------------cut here---------------start------------->8---
...
In guix/scripts/build.scm:
   808:49  3 (_ "/gnu/store/wvr6byljawdlxgxabl6798i0afqgpyiq-hello-w?")
In guix/derivations.scm:
    709:7  2 (derivation->output-paths "/gnu/store/wvr6byljawdlxgxab?")
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure struct-vtable: Wrong type argument in position 1 (expecting 
struct): "/gnu/store/wvr6byljawdlxgxabl6798i0afqgpyiq-hello-world"
--8<---------------cut here---------------end--------------->8---

In my opinion, being able to directly build file-like objects from the
command line is a useful feature and should be better supported. I don't
know if the ideal fix involves changing the guix-build command in
guix/scripts/build.scm to stop assuming everything is a derivation or
changing the logic in guix/derivations.scm to handle strings in addition
to derivation structs.

Possible related: 
https://lists.gnu.org/archive/html/bug-guix/2022-07/msg00037.html.

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]