unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69836: Guix build builds but errors when given file-like object
@ 2024-03-17  2:48 Richard Sent
  0 siblings, 0 replies; only message in thread
From: Richard Sent @ 2024-03-17  2:48 UTC (permalink / raw)
  To: 69836

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.




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-17  3:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-17  2:48 bug#69836: Guix build builds but errors when given file-like object Richard Sent

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).