From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Pykhalov Subject: bug#34884: guix describe fails with --format=json and --format=recutils Date: Sat, 16 Mar 2019 17:11:22 +0300 Message-ID: <87zhpuucxh.fsf@gmail.com> References: <871s37unyz.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:48489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5AId-0007KF-EQ for bug-guix@gnu.org; Sat, 16 Mar 2019 10:28:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h5A2d-0003A9-6u for bug-guix@gnu.org; Sat, 16 Mar 2019 10:12:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33066) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h5A2c-00039c-LU for bug-guix@gnu.org; Sat, 16 Mar 2019 10:12:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h5A2c-0007dR-Ao for bug-guix@gnu.org; Sat, 16 Mar 2019 10:12:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <871s37unyz.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Sat, 16 Mar 2019 11:12:52 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Pierre Neidhardt Cc: 34884@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain 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 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 # # _) > 829:9 1 (catch system-error # # _) > 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 # # _) > 829:9 1 (catch system-error # # _) > 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--- --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-describe-Handle-JSON-and-recutils-formats-for-GUIX_P.patch Content-Transfer-Encoding: quoted-printable Content-Description: [PATCH] describe: Handle JSON and recutils formats for From=204f911d60f96f088876e6bcbed1883cff637507c2 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Sat, 16 Mar 2019 16:56:34 +0300 Subject: [PATCH] describe: Handle JSON and recutils formats for 'GUIX_PACKAGE_PATH'. Fixes . Reported by Pierre Neidhardt . * guix/scripts/describe.scm (display-package-search-path): Handle JSON and recutils formats. =2D-- 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 =2D-- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2018 Ludovic Court=C3=A8s =2D;;; Copyright =C2=A9 2018 Oleg Pykhalov +;;; Copyright =C2=A9 2018, 2019 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; @@ -77,6 +77,16 @@ Display information about the channels currently in use.= \n")) =20 (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 spa= ce + ;; 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=3D\"~a\"~%" string)) ('channels =2D (format #t (G_ "~%;; warning: GUIX_PACKAGE_PATH=3D\"~a\"~%") =2D string)))))) + (format (current-warning-port) + (G_ "~%;; warning: GUIX_PACKAGE_PATH=3D\"~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))))))) =20 (define (channel->sexp channel) `(channel =2D-=20 2.21.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAlyNBAoACgkQFn+OpQAa +pz/bQ/9FiGwb9qkgioTrsj141Y114+OQi7155IOgqUd/C1/yR0pLC1wjN27ejBH vjQbUHRrXGC7ksQFljFrvOutqC/GXLRwauhe1P5c/M+26jLjU5UC65Ir/+q7xLf0 FvIB2OJ5lVTyZ0CZHghHd9xlFnna5/WZs1KlXQvZ4kWBSxzLY/ruryb9Nhe1xPrT 8Gx6YY84YePEr+T2HKW7x/p/dU89vF0hQPbM1kwRYF9g4j8JM2rsaZUUM4ZSwWgN YrLXtpL+7X+gJlgSQEMjwMiMz3OFaKSAPcnA2A6PS8U2KrVG2mWQi4Q2on10+Tgp IAd08XHwS/uHuBija+nSPaGmf6G2pBu0tLJdju0ExnJmroQD1/0qmt/uPI+kcvE5 xxlkVJrHGradSI0MDkKZLSdbEKiB2Tf7GCOm8M2GkKO0eCN5HFu5LhMeZh3I58wB ZARbb4jJ2CbJMLenhN7zHhukNYN94cYtL7CabmJ6Wrh4JwWpk4nkYA5OqpLM/8GU aRDFA7Dxs59NGhVNbrgsdD+1QouD/YsrIUGo9ilVmDBVbyZy9s33VdQbllmJnwp4 9vLPWiZyCf/TFNJMAEGuAP6CY9EdHPaGuZExZLWjrUu2L8UURHf5KdSOpsaqTcNg Keubcc3aV5Kg9Sh7YcX/PPHjTiR0ZiSW1wdNit+L+z+mLSdA5XY= =lDJr -----END PGP SIGNATURE----- --==-=-=--