Subject: [bug#34249] [PATCH] guix package: Avoid spinner at end of output.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 29 Jan 2019 23:46:03 +0100

Danny Milosavljevic <[email-masked]> skribis:

> Hi Christopher,
>> diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
>> index a633d2ee6d..4db0e72e9b 100644
>> --- a/guix/scripts/package.scm
>> +++ b/guix/scripts/package.scm
>> @@ -159,6 +159,7 @@ hooks\" run when building the profile."
>>                 (switch-symlinks profile (basename name))
>>                 (unless (string=? profile %current-profile)
>>                   (register-gc-root store name))
>> +               (display "\r") ; erase the spinner
>
> In order to actually erase it, might want to do (display "\r\x1b[K") instead.

And to do that, you can use (erase-current-line port).

Though actually I think this should be done in ‘print-build-event’ in
(guix status).  Probably something like the patch below, but I haven’t
been able to quickly reproduce the initial problem.

Could you give it a spin (ah ha!) and report back?

If it doesn’t solve the issue, we should strace the thing to see why it
keeps spinning after everything is “done” basically.

Thanks,
Ludo’.

diff --git a/guix/status.scm b/guix/status.scm
index e3375816c5..7a330525b0 100644
--- a/guix/status.scm
+++ b/guix/status.scm
@@ -465,8 +465,14 @@ addition to build events."
             (_
              (spin! port))))))
 
-  (unless print-log?
-    (display "\r" port))                          ;erase the spinner
+  (define erase-current-line*
+    (if (isatty?* port)
+        (lambda (port)
+          (erase-current-line port)
+          (force-output port))
+        (const #t)))
+
+  (erase-current-line* port)                      ;clear the spinner
   (match event
     (('build-started drv . _)
      (let ((properties (derivation-properties