bug-guix
[Top][All Lists]
Advanced

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

bug#34884: guix describe fails with --format=json and --format=recutils


From: Oleg Pykhalov
Subject: bug#34884: guix describe fails with --format=json and --format=recutils
Date: Sat, 16 Mar 2019 17:11:22 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hello Pierre,

Good catch!  I prepared a patch in the attachement bellow to fix this.

Also the patch changes behavior of '--format=channels' for
'GUIX_PACKAGE_PATH' warning.  It will print to STDERR instead of STDOUT.

Pierre Neidhardt <address@hidden> writes:

>> guix describe --format=json
> [{"name":"guix","url":"https://git.savannah.gnu.org/git/guix.git","commit":"77f3d3036406b1d1ceaeba8017ae5f597f2a0fb4"}]
> Backtrace:
>            4 (primitive-load "/home/ambrevar/.config/guix/current/bin/guix")
> In guix/ui.scm:
>   1654:12  3 (run-guix-command _ . _)
> In ice-9/boot-9.scm:
>     829:9  2 (catch srfi-34 #<procedure 2ff58a0 at guix/ui.scm:624:2 ()> 
> #<procedure 7f711b6c39b8 at guix/ui.scm:624:2 (key c)> _)
>     829:9  1 (catch system-error #<procedure 2ff5940 at 
> guix/scripts/describe.scm:203:4 ()> #<procedure 7f711b6c39d0 at 
> guix/ui.scm:750:6 (key proc format-string format-args . rest)> _)
> In guix/scripts/describe.scm:
>      83:5  0 (display-package-search-path json)
>
> guix/scripts/describe.scm:83:5: In procedure display-package-search-path:
> Throw to key `match-error' with args `("match" "no matching pattern" json)'.

JSON format:
--8<---------------cut here---------------start------------->8---
address@hidden ~/src/guix$ ./pre-inst-env env 
GUIX_PACKAGE_PATH=$HOME/src/guix-wigust:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist
 guix describe -p ~/.config/guix/current --format=json
[{"name":"guix","url":"https://gitlab.wugi.info/guix/guix.git","commit":"4161deb4549c39b7d4801cc8aa63c365d19fc649"},{"name":"guix-wigust","url":"https://gitlab.wugi.info/guix/guix-wigust.git","commit":"f6dfa5fc08824ebe5bdc42ea35ff0e040245c8c0"}]
{"name":"GUIX_PACKAGE_PATH","paths":["/home/oleg/src/guix-wigust","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist","/tmp/noexist"]}
--8<---------------cut here---------------end--------------->8---

>> guix describe -f recutils
> name: guix
> url: https://git.savannah.gnu.org/git/guix.git
> commit: 77f3d3036406b1d1ceaeba8017ae5f597f2a0fb4
>
> Backtrace:
>            4 (primitive-load "/home/ambrevar/.config/guix/current/bin/guix")
> In guix/ui.scm:
>   1654:12  3 (run-guix-command _ . _)
> In ice-9/boot-9.scm:
>     829:9  2 (catch srfi-34 #<procedure 2ac1d20 at guix/ui.scm:624:2 ()> 
> #<procedure 7fa6695719b8 at guix/ui.scm:624:2 (key c)> _)
>     829:9  1 (catch system-error #<procedure 2ac1dc0 at 
> guix/scripts/describe.scm:203:4 ()> #<procedure 7fa6695719d0 at 
> guix/ui.scm:750:6 (key proc format-string format-args . rest)> _)
> In guix/scripts/describe.scm:
>      83:5  0 (display-package-search-path recutils)
>
> guix/scripts/describe.scm:83:5: In procedure display-package-search-path:
> Throw to key `match-error' with args `("match" "no matching pattern" 
> recutils)'.

recutils format:
--8<---------------cut here---------------start------------->8---
address@hidden ~/src/guix$ ./pre-inst-env env 
GUIX_PACKAGE_PATH=$HOME/src/guix-wigust:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist:/tmp/noexist
 guix describe -p ~/.config/guix/current --format=recutils
name: guix
url: https://gitlab.wugi.info/guix/guix.git
commit: 4161deb4549c39b7d4801cc8aa63c365d19fc649

name: guix-wigust
url: https://gitlab.wugi.info/guix/guix-wigust.git
commit: f6dfa5fc08824ebe5bdc42ea35ff0e040245c8c0

name: GUIX_PACKAGE_PATH
paths: /home/oleg/src/guix-wigust /tmp/noexist /tmp/noexist /tmp/noexist 
/tmp/noexist
+ /tmp/noexist /tmp/noexist /tmp/noexist /tmp/noexist /tmp/noexist /tmp/noexist 
/tmp/noexist
+ /tmp/noexist /tmp/noexist /tmp/noexist /tmp/noexist /tmp/noexist /tmp/noexist 
/tmp/noexist

--8<---------------cut here---------------end--------------->8---

From 4f911d60f96f088876e6bcbed1883cff637507c2 Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <address@hidden>
Date: Sat, 16 Mar 2019 16:56:34 +0300
Subject: [PATCH] describe: Handle JSON and recutils formats for
 'GUIX_PACKAGE_PATH'.

Fixes <https://bugs.gnu.org/34884>.
Reported by Pierre Neidhardt <address@hidden>.

* guix/scripts/describe.scm (display-package-search-path): Handle JSON and
recutils formats.
---
 guix/scripts/describe.scm | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm
index 7d0ecb0a4d..fbc142426e 100644
--- a/guix/scripts/describe.scm
+++ b/guix/scripts/describe.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018 Ludovic Courtès <address@hidden>
-;;; Copyright © 2018 Oleg Pykhalov <address@hidden>
+;;; Copyright © 2018, 2019 Oleg Pykhalov <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,6 +77,16 @@ Display information about the channels currently in use.\n"))
 
 (define (display-package-search-path fmt)
   "Display GUIX_PACKAGE_PATH, if it is set, according to FMT."
+  (define* (paths->recutils paths #:optional (width (%text-width)))
+    (define width*
+      ;; The available number of columns once we've taken into account space
+      ;; for the initial "+ " prefix.
+      (if (> width 2) (- width 2) %text-width))
+
+    (string->recutils
+     (fill-paragraph (string-join (string-split paths #\:)) width*
+                     (string-length "dependencies: "))))
+
   (match (getenv "GUIX_PACKAGE_PATH")
     (#f #t)
     (string
@@ -84,8 +94,18 @@ Display information about the channels currently in use.\n"))
        ('human
         (format #t "~%GUIX_PACKAGE_PATH=\"~a\"~%" string))
        ('channels
-        (format #t (G_ "~%;; warning: GUIX_PACKAGE_PATH=\"~a\"~%")
-                string))))))
+        (format (current-warning-port)
+                (G_ "~%;; warning: GUIX_PACKAGE_PATH=\"~a\"~%") string))
+       ('json
+        (format (current-warning-port)
+                (scm->json-string
+                 `((name . "GUIX_PACKAGE_PATH")
+                   (paths . ,(string-split string #\:))))))
+       ('recutils
+        (format (current-warning-port)
+                "name: GUIX_PACKAGE_PATH")
+        (format (current-warning-port)
+                "~%paths: ~a~%~%" (paths->recutils string)))))))
 
 (define (channel->sexp channel)
   `(channel
-- 
2.21.0

Attachment: signature.asc
Description: PGP signature


reply via email to

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