From: Oleg Pykhalov <go.wigust@gmail.com>
To: Pierre Neidhardt <mail@ambrevar.xyz>
Cc: 34884@debbugs.gnu.org
Subject: bug#34884: guix describe fails with --format=json and --format=recutils
Date: Sat, 16 Mar 2019 17:11:22 +0300 [thread overview]
Message-ID: <87zhpuucxh.fsf@gmail.com> (raw)
In-Reply-To: <871s37unyz.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Sat, 16 Mar 2019 11:12:52 +0100")
[-- Attachment #1.1: Type: text/plain, Size: 4186 bytes --]
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 <mail@ambrevar.xyz> 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---
oleg@guixsd ~/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---
oleg@guixsd ~/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---
[-- Attachment #1.2: [PATCH] describe: Handle JSON and recutils formats for --]
[-- Type: text/x-patch, Size: 2584 bytes --]
From 4f911d60f96f088876e6bcbed1883cff637507c2 Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <go.wigust@gmail.com>
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 <mail@ambrevar.xyz>.
* 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 <ludo@gnu.org>
-;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2018, 2019 Oleg Pykhalov <go.wigust@gmail.com>
;;;
;;; 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2019-03-16 14:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-16 10:12 bug#34884: guix describe fails with --format=json and --format=recutils Pierre Neidhardt
2019-03-16 14:11 ` Oleg Pykhalov [this message]
2019-03-17 15:40 ` Ludovic Courtès
2019-03-17 17:40 ` Oleg Pykhalov
2019-03-18 8:52 ` Ludovic Courtès
2019-03-18 8:45 ` Ricardo Wurmus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zhpuucxh.fsf@gmail.com \
--to=go.wigust@gmail.com \
--cc=34884@debbugs.gnu.org \
--cc=mail@ambrevar.xyz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).