From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Marusich Subject: Mysterious error while refactoring guix/scripts/system.scm Date: Wed, 03 Aug 2016 23:20:00 -0700 Message-ID: <87wpjxhx7z.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVC0u-0007pD-1D for guix-devel@gnu.org; Thu, 04 Aug 2016 02:20:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVC0s-00044j-AI for guix-devel@gnu.org; Thu, 04 Aug 2016 02:20:15 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, In my local Guix git repo, I've made the attached change on top of commit 7972d8a2e98af6592050a37036c2c80a01358fcf. I was surprised to find that when I built it and ran './pre-inst-env guix system list-generations', the following error occurred: =2D-8<---------------cut here---------------start------------->8--- Backtrace: In ice-9/boot-9.scm: 157: 19 [catch system-error ...] In guix/scripts/system.scm: 884: 18 [#] 818: 17 [process-command list-generations () ...] In guix/store.scm: 1182: 16 [run-with-store # ...] In guix/scripts/system.scm: 819: 15 [# #] In guix/packages.scm: 1092: 14 [# #] 734: 13 [cache! # # # ...] 1038: 12 [thunk] 970: 11 [bag->derivation # # #] In srfi/srfi-1.scm: 578: 10 [map # = #] In guix/packages.scm: 794: 9 [expand-input # # # ...] In guix/store.scm: 1182: 8 [run-with-store # ...] In guix/packages.scm: 1140: 7 [# #] In guix/download.scm: 326: 6 [# #] In guix/store.scm: 1105: 5 [# #] In guix/packages.scm: 734: 4 [cache! # # # ...] 1038: 3 [thunk] In gnu/packages/bootstrap.scm: 191: 2 [raw-build # "guile-bootstrap-2.0" ...] In gnu/packages.scm: 91: 1 [search-bootstrap-binary "tar" #] In unknown file: ?: 0 [string-append # "/" "tar"] ERROR: In procedure string-append: ERROR: In procedure string-append: Wrong type (expecting string): # =2D-8<---------------cut here---------------end--------------->8--- I don't have much experience (yet!) debugging Guile programs, so I haven't been able to understand the cause of the issue despite my attempts. Can anyone help me understand the problem, or provide tips on how to debug this more effectively? The motivation for this refactoring is as follows. I want to eventually add procedures 'roll-back-system' and 'switch-to-system-generation', which respectively roll the system back to a previous generation, and switch to an existing generation. These new procedures will require access to the store (e.g., to regenerate grub.cfg). I must invoke those procedures somewhere in (guix scripts system), and the obvious place to do that is inside the 'process-action' procedure. However, that procedure is written with the assumption that the action requires an operating system configuration file. My two new procedures don't require that. So, instead, I thought it would be easiest to pull the store monad setup logic (the 'with-store' stuff) up one level into the procedure 'process-command' and call my two new procedures inside the 'process-command' procedure. It looked to me like there was nothing specific about the store monad setup logic that required it to exist in the 'process-action' procedure, so I thought this refactoring would be simple and clean. I was apparently wrong, but I can't see why. This is the last thing blocking me from submitting patches to the email list which add system roll-back and switch-generation commands to GuixSD. I have a series of commits on a branch in my Guix git repo which implement system-rollback and switch-generation. If you'd like to see them for more context, please let me know and I'll provide them, too. Thank you! =2D-=20 Chris --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Refactor-process-action-and-process-command.patch Content-Transfer-Encoding: quoted-printable From=201f3a08b080c75b9be7c74235637cce0f91a249d5 Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Wed, 3 Aug 2016 00:39:39 -0700 Subject: [PATCH] Refactor process-action and process-command =2D-- guix/scripts/system.scm | 73 ++++++++++++++++++++++++---------------------= ---- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index e2c6b2e..8302d57 100644 =2D-- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -785,47 +785,46 @@ resulting from command-line parsing." (grub-configuration-device (operating-system-bootloader os))))) =20 =2D (with-store store =2D (set-build-options-from-command-line store opts) =2D =2D (run-with-store store =2D (mbegin %store-monad =2D (set-guile-for-build (default-guile)) =2D (case action =2D ((extension-graph) =2D (export-extension-graph os (current-output-port))) =2D ((shepherd-graph) =2D (export-shepherd-graph os (current-output-port))) =2D (else =2D (perform-action action os =2D #:dry-run? dry? =2D #:derivations-only? (assoc-ref opts =2D 'derivations= -only?) =2D #:use-substitutes? (assoc-ref opts 'substit= utes?) =2D #:image-size (assoc-ref opts 'image-size) =2D #:full-boot? (assoc-ref opts 'full-boot?) =2D #:mappings (filter-map (match-lambda =2D (('file-system-map= ping . m) =2D m) =2D (_ #f)) =2D opts) =2D #:grub? grub? =2D #:target target #:device device)))) =2D #:system system)))) + (case action + ((extension-graph) + (export-extension-graph os (current-output-port))) + ((shepherd-graph) + (export-shepherd-graph os (current-output-port))) + (else + (perform-action action os + #:dry-run? dry? + #:derivations-only? (assoc-ref opts + 'derivations-only?) + #:use-substitutes? (assoc-ref opts 'substitutes?) + #:image-size (assoc-ref opts 'image-size) + #:full-boot? (assoc-ref opts 'full-boot?) + #:mappings (filter-map (match-lambda + (('file-system-mapping . m) + m) + (_ #f)) + opts) + #:grub? grub? + #:target target #:device device))))) =20 (define (process-command command args opts) "Process COMMAND, one of the 'guix system' sub-commands. ARGS is its argument list and OPTS is the option alist." =2D (case command =2D ((list-generations) =2D ;; List generations. No need to connect to the daemon, etc. =2D (let ((pattern (match args =2D (() "") =2D ((pattern) pattern) =2D (x (leave (_ "wrong number of arguments~%")))))) =2D (list-generations pattern))) =2D (else =2D (process-action command args opts)))) + (with-store store + (set-build-options-from-command-line store opts) + + (run-with-store store + (mbegin %store-monad + (set-guile-for-build (default-guile)) + (case command + ((list-generations) + (let ((pattern (match args + (() "") + ((pattern) pattern) + (x (leave (_ "wrong number of arguments~%"))))= )) + (list-generations pattern))) + (else + (process-action command args opts)))) + #:system system))) =20 (define (guix-system . args) (define (parse-sub-command arg result) =2D-=20 2.7.3 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXot6SAAoJEN1AmhXYIkadrBEP/3UQofFthvR50BuUjevi6vLn 5xie8tXzxp4uHl7Pi58yLYEGZ6rGytQKPpLSX+jthFW6QFqscoopUXHQnDSlVJ4J 8652rexjsJjGnw+9teiXHoI2FIc4EMWcL/DZgoDFJizRpINFh/6+HYJM96vx3jjp rG6gHlPJeXlNaQHh9Ps2pWiSttAda3Zs6oQmqSD20ZvaqXN6IDJoSoG1dQYi9zkB AvS9tRunsugB+s//0g0jDKMk+ej8xItn8k64TSHa1fxiLfb26PAFtG9KS/C8FVKV Hi3B2t9PWyrvENSGMUCXgOkjhZhg4mccxGaggRWZ02HUHHrbdJQ8beaHHCaYv+4e b8MdjfGT//OCsekn++ZH+B3L8/u21Qc9NH5udf53Meo3Mbupd+fr8Oy5uv4x9qes uCfCxY0yj+T344MArUnoOJ72s40iAJJVwqfJaZkTzVyTX1qym6dUU7+MO49ld4hw FcndKn1xRWQzzhDBMVDPid7jmqBSPyyXgd4mxBlIqvwxEYOI7lI8fhtRePNoiNR7 9NMFRetI45m5nBH2A9gjDwnpbkDGRFBFJtOYOHbXcZDeJW3Ih0dOZuG7xNnvlnER JRIHNDw2UksOLP3RerqUlPPBx8OOpS/m1jb1HmsEWw+ij7+yJNvPcGZmXmhHK/48 xjYIbpulZORc5GMf2GrM =t1+X -----END PGP SIGNATURE----- --==-=-=--