unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chris Marusich <cmmarusich@gmail.com>
To: Andy Wingo <wingo@igalia.com>
Cc: guix-devel@gnu.org
Subject: Re: Mysterious error while refactoring guix/scripts/system.scm
Date: Wed, 10 Aug 2016 00:23:29 -0700	[thread overview]
Message-ID: <8737md3x5a.fsf@gmail.com> (raw)
In-Reply-To: <87poppq85f.fsf@igalia.com> (Andy Wingo's message of "Thu, 04 Aug 2016 09:56:44 +0200")


[-- Attachment #1.1: Type: text/plain, Size: 4497 bytes --]


Hi Andy,

Thank you for the help!  Sorry for the late reply; I wasn't able to
respond until just now.

> Here the #:system system was taking the `system' binding from within the
> function -- it was lexically bound.

You're right; that was the problem.  I've updated the patch (see
attached) and applied it again to
7972d8a2e98af6592050a37036c2c80a01358fcf, but when I built the new
version and ran './pre-inst-env guix system list-generations', the
following new error occurred (after successfully printing the list of
generations):

--8<---------------cut here---------------start------------->8---
Generation 1	Jul 29 2016 08:26:37
  file name: /var/guix/profiles/system-1-link
  canonical file name: /gnu/store/90xaq1d04g39c1wmxplngh3hhc1h5z7g-system
  label: GNU with Linux-Libre 4.7 (beta)
  root device: /dev/sda1
  kernel: /gnu/store/p7wbfpbs8p8ykdrn1440f95ap9iq1czh-linux-libre-4.7
Generation 2	Aug 03 2016 07:35:00
  file name: /var/guix/profiles/system-2-link
  canonical file name: /gnu/store/6il3znhh2cyp3xw0800x6m3yjq8jq5z9-system
  label: GNU with Linux-Libre 4.7 (beta)
  root device: my-root
  kernel: /gnu/store/p7wbfpbs8p8ykdrn1440f95ap9iq1czh-linux-libre-4.7
Generation 3	Aug 03 2016 07:38:12
  file name: /var/guix/profiles/system-3-link
  canonical file name: /gnu/store/74d698pk4dwv4k4bvf2n4b7j4bg0gbq0-system
  label: GNU with Linux-Libre 4.7 (beta)
  root device: #vu8(18 55 238 217 114 62 64 185 130 140 206 84 109 78 188 217)
  kernel: /gnu/store/p7wbfpbs8p8ykdrn1440f95ap9iq1czh-linux-libre-4.7
Generation 4	Aug 03 2016 07:55:20	(current)
  file name: /var/guix/profiles/system-4-link
  canonical file name: /gnu/store/01fd40gf19syn493y2f6h35cb58kqmg4-system
  label: GNU with Linux-Libre 4.7 (beta)
  root device: #vu8(18 55 238 217 114 62 64 185 130 140 206 84 109 78 188 217)
  kernel: /gnu/store/p7wbfpbs8p8ykdrn1440f95ap9iq1czh-linux-libre-4.7
Backtrace:
In ice-9/boot-9.scm:
 157: 15 [catch #t #<catch-closure 26304a0> ...]
In unknown file:
   ?: 14 [apply-smob/1 #<catch-closure 26304a0>]
In ice-9/boot-9.scm:
  63: 13 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 12 [eval # #]
In ice-9/boot-9.scm:
2401: 11 [save-module-excursion #<procedure 264f940 at ice-9/boot-9.scm:4045:3 ()>]
4050: 10 [#<procedure 264f940 at ice-9/boot-9.scm:4045:3 ()>]
1724: 9 [%start-stack load-stack ...]
1729: 8 [#<procedure 2668ea0 ()>]
In unknown file:
   ?: 7 [primitive-load "/root/guix/scripts/guix"]
In guix/ui.scm:
1209: 6 [run-guix-command system "list-generations"]
In ice-9/boot-9.scm:
 157: 5 [catch srfi-34 #<procedure 52af180 at guix/ui.scm:425:2 ()> ...]
 157: 4 [catch system-error ...]
In guix/scripts/system.scm:
 884: 3 [#<procedure 52ae750 at guix/scripts/system.scm:876:2 ()>]
 818: 2 [process-command list-generations () ...]
In guix/store.scm:
1182: 1 [run-with-store # ...]
In unknown file:
   ?: 0 [#<unspecified> #<build-daemon 256.15 52b8e80>]

ERROR: In procedure #<unspecified>:
ERROR: Wrong type to apply: #<unspecified>
--8<---------------cut here---------------end--------------->8---

I'm hoping you can help me (1) understand this particular problem, and
(2) help me learn to become more self-sufficient at troubleshooting
these kinds of issues going forward.  I don't want to have to bother you
or the mailing list every time I encounter a stack trace.

Regarding (1), I'm having trouble understanding this particular stack
trace.  Where did the error occur?  What caused it?  I'm used to stack
traces in Java and Python, where often the exact line which threw an
exception is usually obvious in the stack trace.  I'm finding Guile's
stack traces more difficult to understand.  Maybe I'm just not used to
them yet.

Regarding (2), I've read some of the manual at '(guile) Debugging'
(mainly '(guile) Evaluation Model' and '(guile) Programmatic Error
Handling'), and although it's great and detailed, it isn't obvious to me
how to apply that knowledge in practice.  For example, I'm not even sure
how to find out what the parts and symbols in the above stack trace
mean.  How can I get better at this?  Should I just read the rest of
'(guile) Debugging' in detail, and experiment with my own toy programs
until it makes more sense?  Or is there a common tool people use for
debugging that I'm not aware of, like how pdb is a common debugging tool
for Python programs?

Again, thank you for your help.  I really appreciate it!

-- 
Chris

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Refactor-process-action-and-process-command.patch --]
[-- Type: text/x-patch, Size: 4724 bytes --]

From a3e094e5393ac7289075a0b63696bd9e5024b202 Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Wed, 3 Aug 2016 00:39:39 -0700
Subject: [PATCH] Refactor process-action and process-command

---
 guix/scripts/system.scm | 74 ++++++++++++++++++++++++-------------------------
 1 file changed, 36 insertions(+), 38 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 209ebf9..731e3cd 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -774,7 +774,6 @@ resulting from command-line parsing."
   (let* ((file     (match args
                      (() #f)
                      ((x . _) x)))
-         (system   (assoc-ref opts 'system))
          (os       (if file
                        (load* file %user-module
                               #:on-error (assoc-ref opts 'on-error))
@@ -789,47 +788,46 @@ resulting from command-line parsing."
                         (grub-configuration-device
                          (operating-system-bootloader os)))))
 
-    (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 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))))
-        #: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)))))
 
 (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."
-  (case command
-    ((list-generations)
-     ;; List generations.  No need to connect to the daemon, etc.
-     (let ((pattern (match args
-                      (() "")
-                      ((pattern) pattern)
-                      (x (leave (_ "wrong number of arguments~%"))))))
-       (list-generations pattern)))
-    (else
-     (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 (assoc-ref opts 'system))))
 
 (define (guix-system . args)
   (define (parse-sub-command arg result)
-- 
2.7.3


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

  reply	other threads:[~2016-08-10  7:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  6:20 Mysterious error while refactoring guix/scripts/system.scm Chris Marusich
2016-08-04  7:56 ` Andy Wingo
2016-08-10  7:23   ` Chris Marusich [this message]
2016-08-29 15:53     ` Ludovic Courtès
2016-09-24 19:54       ` Chris Marusich
2016-09-30 20:36         ` Ludovic Courtès

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=8737md3x5a.fsf@gmail.com \
    --to=cmmarusich@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=wingo@igalia.com \
    /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).