GNU bug report logs - #51466
guix shell --check reports missing PKG_CONFIG_PATH on Debian bookworm

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix; Reported by: Vagrant Cascadian <vagrant@HIDDEN>; Keywords: moreinfo; merged with #53355; dated Thu, 28 Oct 2021 19:10:02 UTC; Maintainer for guix is bug-guix@HIDDEN.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 20 May 2022 21:37:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 20 17:37:13 2022
Received: from localhost ([127.0.0.1]:40230 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nsAJ7-0003JC-1A
	for submit <at> debbugs.gnu.org; Fri, 20 May 2022 17:37:13 -0400
Received: from eggs.gnu.org ([209.51.188.92]:49114)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>)
 id 1nsAJ2-0003Iu-Q3; Fri, 20 May 2022 17:37:12 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:36986)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1nsAIx-0000tB-I0; Fri, 20 May 2022 17:37:03 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=LoiQClw0DtGGGsv/FJeKsbt4/buWO5r2aXfPbQIanGg=; b=Gpp8JA3QtrQ+6dDkzuhu
 O/ZUv4IgyiZtzgB5NgG8i1hoK1F1jg59EMiWdxfD0dsU00Ka4NP/DL5QAmuA9CW8bGurpI7K6rtqE
 76+Xv94wB7BDlbWjLGNbhgu+Bj83AsYqfqZBgKjZPahyeNW0LGCDIGK6IUPZ7dUIVmLxWyn/tn7W/
 r3LV5J+nwNSWpAYVKb4Gmaa73iFBSQj/erxjuPmRg4bQaeLIloo2ux2STnxICIGR545UeDA3CLRn/
 pO8sVEs11dZY93aXSZmxCYRYWJnc28Jx1oXLhU29u7dTHGC8wBmxJjyZXTF4HiNw5RcsUjzt2XoML
 WhFj/swpQLVEUQ==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:49206
 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1nsAIx-00016h-4n; Fri, 20 May 2022 17:37:03 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Chris Marusich <cmmarusich@HIDDEN>
Subject: Re: bug#53355: guix shell --check: confusing error message
References: <87h7a08kub.fsf@HIDDEN> <87lez5td4n.fsf@HIDDEN>
 <87sftc4osu.fsf@HIDDEN> <87h79slysd.fsf@HIDDEN>
 <87sft13dyv.fsf@HIDDEN> <874k59d802.fsf@HIDDEN>
 <87wnhy2w73.fsf_-_@HIDDEN> <878rudzsmv.fsf@HIDDEN>
 <87ilso461i.fsf_-_@HIDDEN>
Date: Fri, 20 May 2022 23:37:01 +0200
In-Reply-To: <87ilso461i.fsf_-_@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s?=
 =?utf-8?Q?=22's?= message of "Tue, 08 Mar 2022 20:07:21 +0100")
Message-ID: <8735h3x4w2.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51466
Cc: 53355 <at> debbugs.gnu.org, 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Chris,

A friendly ping.  :-)

Ludo=E2=80=99.

Ludovic Court=C3=A8s <ludo@HIDDEN> skribis:

> Hi Chris,
>
> Did you have a chance to look into it?
>
>   https://issues.guix.gnu.org/53355
>
> TIA.  :-)
>
> Ludo=E2=80=99.
>
> Ludovic Court=C3=A8s <ludo@HIDDEN> skribis:
>
>> Hi Chris,
>>
>> Thanks for debugging this!
>>
>> Chris Marusich <cmmarusich@HIDDEN> skribis:
>>
>>> From c3eea81846ae71a246e6b592be74062f4bf26474 Mon Sep 17 00:00:00 2001
>>> From: Chris Marusich <cmmarusich@HIDDEN>
>>> Date: Sun, 13 Feb 2022 14:15:14 -0800
>>> Subject: [PATCH] environment: Prevent PS1 from clobbering output in 'ch=
eck'.
>>>
>>> Fixes: <https://issues.guix.gnu.org/51466>.
>>>
>>> * guix/scripts/environment.scm (child-shell-environment): In the script
>>> executed the child shell, set PS1 to an empty value and then echo three
>>> sentinel lines to try to "flush" the original PS1 value before printing=
 the
>>> environment variables.  In the parent process, read and discard all lin=
es up
>>> to and including the last sentinel line.  After that, read the remainin=
g lines
>>> as usual.
>>
>> [...]
>>
>>> +    ;; Why print "GUIX_FLUSH" a few times?  We are trying to "flush" t=
he
>>> +    ;; original PS1 value to the port so we can read it (and discard i=
t)
>>> +    ;; before we start reading the environment variables from the port=
.  If we
>>> +    ;; don't do this, the original PS1 value can sometimes get interle=
aved
>>> +    ;; into the output, which interferes with our parsing logic.  It's=
 a hack,
>>> +    ;; but in practice it seems to do the job.  If you know of a more =
graceful
>>> +    ;; solution, please implement it!  See: https://issues.guix.gnu.or=
g/51466
>>> +    "PS1=3D; for i in 1 2 3; do echo GUIX_FLUSH_$i; done; \
>>> +env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
>>
>> So you confirm that a single =E2=80=9Cecho=E2=80=9D is not enough, right?
>>
>> Perhaps we should unroll the =E2=80=98for=E2=80=99 loop for portability,=
 to be on the
>> safe side.  Initially I tested with Bash, Zsh, and Fish:
>>
>>   https://issues.guix.gnu.org/51285#0-lineno49
>>
>> I think Fish has a very non-POSIX syntax, hence the suggestion to avoid
>> =E2=80=98for=E2=80=99.
>>
>> I realized that setting PS1 could interfere with the logic below that
>> checks for PS1.  And since it doesn=E2=80=99t seem to help, perhaps we c=
an
>> remove =E2=80=9CPS1=3D;=E2=80=9D?
>>
>> Thoughts?
>>
>> Sorry to answer with yet more questions!
>>
>> Thanks,
>> Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 27 Mar 2022 16:59:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 27 12:59:29 2022
Received: from localhost ([127.0.0.1]:56486 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nYWEj-0005sx-30
	for submit <at> debbugs.gnu.org; Sun, 27 Mar 2022 12:59:29 -0400
Received: from mail-ej1-f51.google.com ([209.85.218.51]:39771)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kevinboulain@HIDDEN>) id 1nYWEf-0005sR-O1
 for 51466 <at> debbugs.gnu.org; Sun, 27 Mar 2022 12:59:26 -0400
Received: by mail-ej1-f51.google.com with SMTP id dr20so24208355ejc.6
 for <51466 <at> debbugs.gnu.org>; Sun, 27 Mar 2022 09:59:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=hh+/yP0VKKJunTnXq4xDB/1DhEK360hpOM44ZzirqOQ=;
 b=iLfx1r3KTEeotus7cz0D0Gy93uft+sBi0E8qdyE553d6CPY7o8zGZk+YqYa5ICxuWl
 3wmkITesjT0edl9HkwZaUMGoS2M8NEPTLEDYxhoA9f3v3GQKaPiuyk1fRzgKiEcv1vZi
 TfiXhTiFnYwRn/QAwVN7c3Izk97EZXXvZpcyx3ZRWHaFb9JiH4JHLHSj+Gn9HI53xDtG
 YKDt1lwgJtHUIBcA4a8yt21YXuFbsAuMDaZNS/cl15oE5Gvy7FkoJEgh7kA9Ee49sISF
 48nYacRcUoKjKs//Tk2mFYEVzLpuNC8YprGAlUyxEhAxvSqiiq+LFmbhOkj2zNOQsTCR
 ZmhQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=hh+/yP0VKKJunTnXq4xDB/1DhEK360hpOM44ZzirqOQ=;
 b=6vgxwDp8CMANoLT5dfKKImQvVurX5L3ZJW3llKVhZgCaB1G5l8psroco/OY+lHk3vy
 NqpbTFKBCnPjIu+7Yc9/dPKM2LVRLkm3cIUJY7fTIZ+M2duJyfiRecGiUqCznOa9Z5a8
 i40KUiR+x9OwGcB/ryS6pNr/ZB9u5L16zcPXAvjmTNqFAGCO9lI0GyTWFbRxrZUUjr+7
 l4eaH81HUQNJA8uJlEmprmqLOt+0UpXq0nqgoDo/YqpUhR7jle4USsVfbTZs1YXgJr7x
 ddJ7447Owpqb713pCrGahFD8cBzTI3Xmgc2nmwtKEymB/1iFhA0rgqiuWFkbM+XWqbuQ
 o+hg==
X-Gm-Message-State: AOAM530vRZ3V9w93DxAYHugeg4G0FnZR55yQ32a490Rv6+89m+w7KtZP
 GB3ni7MPzcO/o1Q3YEYD8CNwKl659BQ=
X-Google-Smtp-Source: ABdhPJxZ8EnEc88oxiRfZRs/ePai28lEZd2NIEv+OFRbV3TnfldkDAQwCVa2SehVoxzMaAzClX4Usg==
X-Received: by 2002:a17:907:72cc:b0:6e0:2d3:bcba with SMTP id
 du12-20020a17090772cc00b006e002d3bcbamr22772349ejc.642.1648400359745; 
 Sun, 27 Mar 2022 09:59:19 -0700 (PDT)
Received: from localhost.localdomain ([51.154.70.17])
 by smtp.gmail.com with ESMTPSA id
 q2-20020a170906144200b006ceb8723de9sm4786243ejc.120.2022.03.27.09.59.19
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 27 Mar 2022 09:59:19 -0700 (PDT)
From: Kevin Boulain <kevinboulain@HIDDEN>
To: 51466 <at> debbugs.gnu.org
Subject: [PATCH 1/1] environment: properly parse environment variables during
 --check
Date: Sun, 27 Mar 2022 19:01:24 +0200
Message-Id: <20220327170124.2846-2-kevinboulain@HIDDEN>
X-Mailer: git-send-email 2.34.0
In-Reply-To: <20220327170124.2846-1-kevinboulain@HIDDEN>
References: <20220327170124.2846-1-kevinboulain@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 51466
Cc: Kevin Boulain <kevinboulain@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Should solve https://issues.guix.gnu.org/51466.

This redirects the env command's output to a temporary file so that
there is no way to get it mixed with the shell's output (like PS1).
Additionnally:
 - Remove GUIX-CHECK-DONE and read: I don't think there is a need for
   them as discarding the output until the shell exits is enough to
   guarantee the environment has been dumped. Sadly, Linux doesn't
   report EOF but EIO when the shell exits and the pty gets closed hence
   the catch/throw.
 - Don't try to parse environment variables by splitting them on \n,
   instead use env's -0 option to separate environment variables with
   \0. This prevent incorrect parsing of some multi-line variables
   (e.g.: f() { echo "hello"; }; declare -fx f) but isn't standard.

* guix/scripts/environment.scm (child-shell-environment): make
environment variables parsing more robust.
* tests/guix-environment.sh: add a simple test that was reliably
failing on my machine.
---
 guix/scripts/environment.scm | 65 +++++++++++++++++++++++-------------
 tests/guix-environment.sh    | 16 +++++++++
 2 files changed, 57 insertions(+), 24 deletions(-)

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index ec071402f4..4ff13c6bde 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -48,7 +48,7 @@ (define-module (guix scripts environment)
   #:autoload   (gnu packages bash) (bash)
   #:autoload   (gnu packages bootstrap) (bootstrap-executable %bootstrap-guile)
   #:use-module (ice-9 match)
-  #:autoload   (ice-9 rdelim) (read-line)
+  #:autoload   (ice-9 rdelim) (read-delimited read-line)
   #:use-module (ice-9 vlist)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
@@ -413,16 +413,22 @@ (define (child-shell-environment shell profile manifest)
   "Create a child process, load PROFILE and MANIFEST, and then run SHELL in
 interactive mode in it.  Return a name/value vhash for all the variables shown
 by running 'set' in the shell."
-  (define-values (controller inferior)
-    (openpty))
-
-  (define script
-    ;; Script to obtain the list of environment variable values.  On a POSIX
-    ;; shell we can rely on 'set', but on fish we have to use 'env' (fish's
-    ;; 'set' truncates values and prints them in a different format.)
-    "env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
-
   (define lines
+    (let* ((environment-port (mkstemp "/tmp/guix-enviroment-XXXXXX"))
+           (environment-file (port-filename environment-port))
+           ;; Script to obtain the list of environment variable values.  On a
+           ;; POSIX shell we can rely on 'set', but on fish we have to use 'env'
+           ;; (fish's 'set' truncates values and prints them in a different
+           ;; format.)
+           ;; We rely on env --null to mark the end of environment variables.
+           ;; This is expected to be safe because POSIX defines environment
+           ;; variables end with '\0' (but does't document the --null option).
+           ;; Some shells, like Bash, allow to export functions, which will span
+           ;; multiple lines and break any trivial parsing relying on '\n'.
+           (script (format #f "env --null > ~a || /usr/bin/env --null > ~a; exit\n"
+                           environment-file environment-file)))
+
+      (let-values (((controller inferior) (openpty)))
         (match (primitive-fork)
           (0
            (catch #t
@@ -436,26 +442,37 @@ (define lines
                (primitive-exit 127))))
           (pid
            (close-fdes inferior)
-       (let* ((port   (fdopen controller "r+l"))
-              (result (begin
+           (let ((port (fdopen controller "r+l")))
              (display script port)
+             (catch 'system-error
+               (lambda ()
+                 ;; We aren't interested in the output of the shell itself,
+                 ;; drop it.
+                 (while (not (eof-object? (read-line port)))))
+               (lambda args
+                 (let ((errno (system-error-errno args)))
+                   (cond
+                    ((= errno EIO)
+                     ;; On Linux, a read won't return EOF but will fail with EIO
+                     ;; when the device is closed:
+                     ;; https://bugs.python.org/issue5380#msg252544
+                     #t)
+                    (#t
+                     (apply throw args))))))
+             (close-port port)
+             (waitpid pid)))))
+
+      (let ((result (begin
                       (let loop ((lines '()))
-                          (match (read-line port)
+                        (match (read-delimited "\0" environment-port)
                           ((? eof-object?) (reverse lines))
-                            ("GUIX-CHECK-DONE\r"
-                             (display "done\n" port)
-                             (reverse lines))
                           (line
-                             ;; Drop the '\r' from LINE.
-                             (loop (cons (string-drop-right line 1)
-                                         lines))))))))
-         (close-port port)
-         (waitpid pid)
-         result))))
+                             (loop (cons line lines))))))))
+        (close-port environment-port)
+        (delete-file environment-file)
+        result)))
 
   (fold (lambda (line table)
-          ;; Note: 'set' in fish outputs "NAME VALUE" instead of "NAME=VALUE"
-          ;; but it also truncates values anyway, so don't try to support it.
           (let ((index (string-index line #\=)))
             (if index
                 (vhash-cons (string-take line index)
diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh
index 95fe95b437..114bf9fbf5 100644
--- a/tests/guix-environment.sh
+++ b/tests/guix-environment.sh
@@ -258,3 +258,19 @@ then
 	guix gc --references "$profile" | grep "$dep"
     done
 fi
+
+# https://issues.guix.gnu.org/51466
+# guix environment --check was sometimes unable to find PKG_CONFIG_PATH
+# because the env command is sent before the prompt gets printed and there
+# is no proper way to deinterleave streams:
+#  ;;; (read-line "env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\r")
+#  ;;; (read-line "bash-5.1$ PKG_CONFIG_PATH=/gnu/store/0ysl5arpf0yf3pn15afr450k676lgdq3-profile/lib/pkgconfig\r")
+#  ;;; (read-line "PWD=/home/ether/source/guix\r")
+bash=$(mktemp)
+cat > "$bash" << 'BASH'
+#!/usr/bin/env bash
+exec bash --noprofile --rcfile /dev/null "$@"
+BASH
+chmod +x "$bash"
+env SHELL=$bash guix environment --check --pure guix -- env
+rm -f "$bash"




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 27 Mar 2022 16:59:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 27 12:59:27 2022
Received: from localhost ([127.0.0.1]:56484 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nYWEg-0005sk-Sx
	for submit <at> debbugs.gnu.org; Sun, 27 Mar 2022 12:59:27 -0400
Received: from mail-ej1-f47.google.com ([209.85.218.47]:45970)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kevinboulain@HIDDEN>) id 1nYWEe-0005sP-KZ
 for 51466 <at> debbugs.gnu.org; Sun, 27 Mar 2022 12:59:24 -0400
Received: by mail-ej1-f47.google.com with SMTP id qa43so24183994ejc.12
 for <51466 <at> debbugs.gnu.org>; Sun, 27 Mar 2022 09:59:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=HMv6W3L7ceA9jgGujKkPJEk+ywO4NmuCvCH4hYA0LQA=;
 b=CCIfhwlT43bknIlEJjWSOackGvViA9guC9AgnKBUR5TAybZ3KoORmw/H452xcwsWM6
 LgOGxsAAx72lg6AAQSvLKDyViT8sW/y10winsMhAAlbl3FrOyeCl/OOGls9LP+1LZX2M
 MFMKTUa8JufOc7QVqXlA1tzizhSSNV/gEpMAdEsAqFkaYeTBw46VLO4ZC3LjEsCwjWBL
 1nywyN0c9yHGr7EUL1uOIToOIoXUMjMgYcWNPcxwSsg3QI16DXwiA1K8sR629RdbubYI
 WCRnlIApWaq8B3QIc4NTDTgnla7Rk6r3Y4VlSpaqnSYhShyQp7fSIsE6qZPKuhmRPEDq
 C1wA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=HMv6W3L7ceA9jgGujKkPJEk+ywO4NmuCvCH4hYA0LQA=;
 b=JEF1IwfEoFljvRoA2LZSL/Jcm/3WPe6z+Ejj4NoMai9SM3dW50OiEPNRmZl/Cx7EAq
 Lc5cFEu06qTl6vux3BOZZ+ZW0JD22Obvt4PCrkBVvVan2ff1LcCFsVZYkKHaWwrbtNKB
 xLlbVgFWVt6yvGVSVIQuHSMtckxe1C99i+leJpiO2Ao+loocHONXV2XTfekbPYXQB+3r
 apjMXh1Sfs8HgPJj7cLlzFgtuMTEGx0H8qX+6/bChYhbky67EaGWxs0FZNFmPzLgvzDd
 1/iAxa06GrFWFGgwhgicKo7qnyzs7EK9tMJXTdPPj+XG9oaJ+Gfq7xdisU9wX2Nvk8Q6
 GNOg==
X-Gm-Message-State: AOAM5321Njv8C8htBZfh+ZUu++DfD+sm2MqRUf3MzEg/6AK3KTPaYP1q
 SrbQnKDSpq6ANv84lqfxg6PzK90k5Ps=
X-Google-Smtp-Source: ABdhPJzze2ebTKOzH0ezI+GEaLA/Xj9O87i1kYPeQ/M/bD8j/oeGzLW+WEH22NFTra2LuuPJLWq3xA==
X-Received: by 2002:a17:907:7ba6:b0:6df:ee7d:10f2 with SMTP id
 ne38-20020a1709077ba600b006dfee7d10f2mr23308594ejc.98.1648400358368; 
 Sun, 27 Mar 2022 09:59:18 -0700 (PDT)
Received: from localhost.localdomain ([51.154.70.17])
 by smtp.gmail.com with ESMTPSA id
 q2-20020a170906144200b006ceb8723de9sm4786243ejc.120.2022.03.27.09.59.17
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 27 Mar 2022 09:59:17 -0700 (PDT)
From: Kevin Boulain <kevinboulain@HIDDEN>
To: 51466 <at> debbugs.gnu.org
Subject: [PATCH 0/1] environment: properly parse environment variables during
 --check
Date: Sun, 27 Mar 2022 19:01:23 +0200
Message-Id: <20220327170124.2846-1-kevinboulain@HIDDEN>
X-Mailer: git-send-email 2.34.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 51466
Cc: Kevin Boulain <kevinboulain@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

The PS1=; for i in 1 2 3; do echo GUIX_FLUSH_$i; done; hack appears to work
for me but here is my alternate version. I don't think we have to hack our way
around the shell if we can dump the environment variables somewhere else.

I added a test but the potato machine I'm running that on is taking a very
long time to run the whole thing (I did run the test in isolation with and
without my patch), would you mind checking it works for you (and can we use
Bash there?).

Note I'm still not sure why we have env || /usr/bin/env (in case we mess with
the PATH I guess?) so I've kept it.

Comments welcome, I haven't coded much in Guile/Scheme.

Kevin Boulain (1):
  environment: properly parse environment variables during --check

 guix/scripts/environment.scm | 65 +++++++++++++++++++++++-------------
 tests/guix-environment.sh    | 16 +++++++++
 2 files changed, 57 insertions(+), 24 deletions(-)





Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 8 Mar 2022 19:07:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 08 14:07:32 2022
Received: from localhost ([127.0.0.1]:57948 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nRfBE-000403-Ee
	for submit <at> debbugs.gnu.org; Tue, 08 Mar 2022 14:07:32 -0500
Received: from eggs.gnu.org ([209.51.188.92]:43640)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>)
 id 1nRfBD-0003zo-5V; Tue, 08 Mar 2022 14:07:31 -0500
Received: from [2001:470:142:3::e] (port=43956 helo=fencepost.gnu.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1nRfB7-0002gJ-Uf; Tue, 08 Mar 2022 14:07:25 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=gIMcQZTk4tANSlYXDYlIuIGOZoc6mjjqqpjcBQjwfjg=; b=lSB30T2tKpYe+LaZ11Li
 HfMkG1yNF4evjI3PI0lHwfTXtqkmLKowllZRFm1/vSoLYLSVUWBN0zqehuJ049ibqyEffLc+Ch4oj
 ojLhiNQWy12Wfiq5D6A5+uIo7N0X9fVfqBKqTi75A7h/MzWN8NSeOpeheD3QRj2pQzTXjux/wucR4
 9Nzilr2Jp7Pnb3GuEQEjw0ZyvQQohZKJQnZE+aGv3OGdGHiPz/E7z/PUt5ZJ39AwnITnzUCo5Duqa
 uhC7cYfbYzu9M+kAtct1l8I2PAHusjXqI8Ilpy4xMHbHpAZmPacI1jkURol+KsxqbgoIblPmY9sy5
 jlUn/e+oStM9cA==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:49420
 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1nRfB6-0003Td-0s; Tue, 08 Mar 2022 14:07:25 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Chris Marusich <cmmarusich@HIDDEN>
Subject: Re: bug#53355: guix shell --check: confusing error message
References: <87h7a08kub.fsf@HIDDEN> <87lez5td4n.fsf@HIDDEN>
 <87sftc4osu.fsf@HIDDEN> <87h79slysd.fsf@HIDDEN>
 <87sft13dyv.fsf@HIDDEN> <874k59d802.fsf@HIDDEN>
 <87wnhy2w73.fsf_-_@HIDDEN> <878rudzsmv.fsf@HIDDEN>
Date: Tue, 08 Mar 2022 20:07:21 +0100
In-Reply-To: <878rudzsmv.fsf@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?=
 =?utf-8?Q?s?= message of "Mon, 14 Feb 2022 10:47:52 +0100")
Message-ID: <87ilso461i.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51466
Cc: 53355 <at> debbugs.gnu.org, 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Chris,

Did you have a chance to look into it?

  https://issues.guix.gnu.org/53355

TIA.  :-)

Ludo=E2=80=99.

Ludovic Court=C3=A8s <ludo@HIDDEN> skribis:

> Hi Chris,
>
> Thanks for debugging this!
>
> Chris Marusich <cmmarusich@HIDDEN> skribis:
>
>> From c3eea81846ae71a246e6b592be74062f4bf26474 Mon Sep 17 00:00:00 2001
>> From: Chris Marusich <cmmarusich@HIDDEN>
>> Date: Sun, 13 Feb 2022 14:15:14 -0800
>> Subject: [PATCH] environment: Prevent PS1 from clobbering output in 'che=
ck'.
>>
>> Fixes: <https://issues.guix.gnu.org/51466>.
>>
>> * guix/scripts/environment.scm (child-shell-environment): In the script
>> executed the child shell, set PS1 to an empty value and then echo three
>> sentinel lines to try to "flush" the original PS1 value before printing =
the
>> environment variables.  In the parent process, read and discard all line=
s up
>> to and including the last sentinel line.  After that, read the remaining=
 lines
>> as usual.
>
> [...]
>
>> +    ;; Why print "GUIX_FLUSH" a few times?  We are trying to "flush" the
>> +    ;; original PS1 value to the port so we can read it (and discard it)
>> +    ;; before we start reading the environment variables from the port.=
  If we
>> +    ;; don't do this, the original PS1 value can sometimes get interlea=
ved
>> +    ;; into the output, which interferes with our parsing logic.  It's =
a hack,
>> +    ;; but in practice it seems to do the job.  If you know of a more g=
raceful
>> +    ;; solution, please implement it!  See: https://issues.guix.gnu.org=
/51466
>> +    "PS1=3D; for i in 1 2 3; do echo GUIX_FLUSH_$i; done; \
>> +env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
>
> So you confirm that a single =E2=80=9Cecho=E2=80=9D is not enough, right?
>
> Perhaps we should unroll the =E2=80=98for=E2=80=99 loop for portability, =
to be on the
> safe side.  Initially I tested with Bash, Zsh, and Fish:
>
>   https://issues.guix.gnu.org/51285#0-lineno49
>
> I think Fish has a very non-POSIX syntax, hence the suggestion to avoid
> =E2=80=98for=E2=80=99.
>
> I realized that setting PS1 could interfere with the logic below that
> checks for PS1.  And since it doesn=E2=80=99t seem to help, perhaps we can
> remove =E2=80=9CPS1=3D;=E2=80=9D?
>
> Thoughts?
>
> Sorry to answer with yet more questions!
>
> Thanks,
> Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 14 Feb 2022 09:48:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 14 04:48:04 2022
Received: from localhost ([127.0.0.1]:39791 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nJXxk-0006ry-7j
	for submit <at> debbugs.gnu.org; Mon, 14 Feb 2022 04:48:04 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:33224)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1nJXxh-0006rK-0W
 for 51466 <at> debbugs.gnu.org; Mon, 14 Feb 2022 04:48:02 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 567884E1;
 Mon, 14 Feb 2022 10:47:54 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id JzYm6IAPnjLx; Mon, 14 Feb 2022 10:47:53 +0100 (CET)
Received: from ribbon (91-160-117-201.subs.proxad.net [91.160.117.201])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 0C8BC3BE;
 Mon, 14 Feb 2022 10:47:53 +0100 (CET)
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Chris Marusich <cmmarusich@HIDDEN>
Subject: Re: bug#53355: guix shell --check: confusing error message
References: <87h7a08kub.fsf@HIDDEN> <87lez5td4n.fsf@HIDDEN>
 <87sftc4osu.fsf@HIDDEN> <87h79slysd.fsf@HIDDEN>
 <87sft13dyv.fsf@HIDDEN> <874k59d802.fsf@HIDDEN>
 <87wnhy2w73.fsf_-_@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 26 =?utf-8?Q?Pluvi=C3=B4se?= an 230 de la
 =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 14 Feb 2022 10:47:52 +0100
In-Reply-To: <87wnhy2w73.fsf_-_@HIDDEN> (Chris Marusich's message of "Sun, 
 13 Feb 2022 15:17:20 -0800")
Message-ID: <878rudzsmv.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 567884E1
X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[];
 RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[];
 TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com];
 TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain];
 RCPT_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[gmail.com];
 FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+];
 RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[];
 MID_RHS_MATCH_FROM(0.00)[]
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 51466
Cc: 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi Chris,

Thanks for debugging this!

Chris Marusich <cmmarusich@HIDDEN> skribis:

> From c3eea81846ae71a246e6b592be74062f4bf26474 Mon Sep 17 00:00:00 2001
> From: Chris Marusich <cmmarusich@HIDDEN>
> Date: Sun, 13 Feb 2022 14:15:14 -0800
> Subject: [PATCH] environment: Prevent PS1 from clobbering output in 'chec=
k'.
>
> Fixes: <https://issues.guix.gnu.org/51466>.
>
> * guix/scripts/environment.scm (child-shell-environment): In the script
> executed the child shell, set PS1 to an empty value and then echo three
> sentinel lines to try to "flush" the original PS1 value before printing t=
he
> environment variables.  In the parent process, read and discard all lines=
 up
> to and including the last sentinel line.  After that, read the remaining =
lines
> as usual.

[...]

> +    ;; Why print "GUIX_FLUSH" a few times?  We are trying to "flush" the
> +    ;; original PS1 value to the port so we can read it (and discard it)
> +    ;; before we start reading the environment variables from the port. =
 If we
> +    ;; don't do this, the original PS1 value can sometimes get interleav=
ed
> +    ;; into the output, which interferes with our parsing logic.  It's a=
 hack,
> +    ;; but in practice it seems to do the job.  If you know of a more gr=
aceful
> +    ;; solution, please implement it!  See: https://issues.guix.gnu.org/=
51466
> +    "PS1=3D; for i in 1 2 3; do echo GUIX_FLUSH_$i; done; \
> +env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")

So you confirm that a single =E2=80=9Cecho=E2=80=9D is not enough, right?

Perhaps we should unroll the =E2=80=98for=E2=80=99 loop for portability, to=
 be on the
safe side.  Initially I tested with Bash, Zsh, and Fish:

  https://issues.guix.gnu.org/51285#0-lineno49

I think Fish has a very non-POSIX syntax, hence the suggestion to avoid
=E2=80=98for=E2=80=99.

I realized that setting PS1 could interfere with the logic below that
checks for PS1.  And since it doesn=E2=80=99t seem to help, perhaps we can
remove =E2=80=9CPS1=3D;=E2=80=9D?

Thoughts?

Sorry to answer with yet more questions!

Thanks,
Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 13 Feb 2022 23:17:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 13 18:17:38 2022
Received: from localhost ([127.0.0.1]:39132 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nJO7c-0007Xv-Tx
	for submit <at> debbugs.gnu.org; Sun, 13 Feb 2022 18:17:38 -0500
Received: from mail-pl1-f177.google.com ([209.85.214.177]:38615)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <cmmarusich@HIDDEN>) id 1nJO7Z-0007Xg-Sd
 for 51466 <at> debbugs.gnu.org; Sun, 13 Feb 2022 18:17:35 -0500
Received: by mail-pl1-f177.google.com with SMTP id c3so9201448pls.5
 for <51466 <at> debbugs.gnu.org>; Sun, 13 Feb 2022 15:17:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=iiEVZTE5lTju0+EWi7oRZo+JjgUrJeOHwGfwt7I/41o=;
 b=lRVDHQCC97ra2GqG8tQiJwL+fW+altPKWGJdsyVn7ta8c6TyiFo1I5y/qEaTSMRrP+
 VGmcjlFTpFnOQ5+P43JN6hJxYFHhp5t+K33LtSixRs8DCwBxU9pAh0x4TWP7dvdiVDDt
 tpdv5U8aOJGO8zezHxaYnNvaBTnPPSNohPuRXq3nyu0eOuA/n64QOK6I1P7EOTUqmRDg
 8GTIka3qgiA46RvDZozqUtM1P5pX/uEw8eGE3aSXT2fYtKaTAZaDFdb9v6neppZKiex/
 YVXgk/J91hIYl4oK+O8PSFBuUy2e8P6cxgx4vWtD+UhGawJFwKZhDoKGLQOl4CSYqELT
 lWNQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=iiEVZTE5lTju0+EWi7oRZo+JjgUrJeOHwGfwt7I/41o=;
 b=ettNd3DGc0/5v/TcnhNuvGyW4/4/PnG69/5wdnnE4pyibOdxmCFlAebwlwN3PxMdrO
 WUruhrJOn9GhiLKQHHdW4JKZCfLvSuBPie+m5EG55fJ8TuDJmnhSecRMKmvl5RaMEs6h
 n2MxFeWNPFiANoGJxQNSdoUB8qXPGccthzKt+okwX4jymqjIubowz3ovqVq8HBGfH+8G
 0axk1JRm9tIIdaTmd3frwbY28OKhbW7/M/IK4rf2lcjPrpg75QmyrviHJDraTDrrPkhB
 mfEaQQryG33kgQw+sNby+2QM6IsEPpRL6wG0giECQ+T/6U2JXudQ1CWIwyUee1BScHLw
 eajg==
X-Gm-Message-State: AOAM533ORySephsE++zHxGp/P5VUAuugsN/xPK4f2dZx3/z72X/EBA2Y
 icxYKilL/AGWEOZmw02StcGz3UjiLBs=
X-Google-Smtp-Source: ABdhPJyNVCaQ4HMTNzA2Re9uzBIaO734glRjMSPooDdj662QrSZE1t9f38JujYtV3nHKxWHrOlFvhw==
X-Received: by 2002:a17:902:ecc1:: with SMTP id
 a1mr7873173plh.111.1644794245942; 
 Sun, 13 Feb 2022 15:17:25 -0800 (PST)
Received: from garuda-lan (c-71-231-157-28.hsd1.wa.comcast.net.
 [71.231.157.28])
 by smtp.gmail.com with ESMTPSA id 13sm12041058pje.50.2022.02.13.15.17.24
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 13 Feb 2022 15:17:25 -0800 (PST)
From: Chris Marusich <cmmarusich@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#53355: guix shell --check: confusing error message
References: <87h7a08kub.fsf@HIDDEN> <87lez5td4n.fsf@HIDDEN>
 <87sftc4osu.fsf@HIDDEN> <87h79slysd.fsf@HIDDEN>
 <87sft13dyv.fsf@HIDDEN> <874k59d802.fsf@HIDDEN>
Date: Sun, 13 Feb 2022 15:17:20 -0800
In-Reply-To: <874k59d802.fsf@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?=
 =?utf-8?Q?s?= message of "Tue, 08 Feb 2022 10:26:21 +0100")
Message-ID: <87wnhy2w73.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="==-=-=";
 micalg=pgp-sha256; protocol="application/pgp-signature"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 51466
Cc: 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--==-=-=
Content-Type: multipart/mixed; boundary="=-=-="

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

Ludovic Court=C3=A8s <ludo@HIDDEN> writes:

> How about this:
>
> diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
> index ec071402f4..ac2c79ab65 100644
> --- a/guix/scripts/environment.scm
> +++ b/guix/scripts/environment.scm
> @@ -420,7 +420,7 @@ (define script
>      ;; Script to obtain the list of environment variable values.  On a P=
OSIX
>      ;; shell we can rely on 'set', but on fish we have to use 'env' (fis=
h's
>      ;; 'set' truncates values and prints them in a different format.)
> -    "env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
> +    "PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; e=
xit\n")
>=20=20
>    (define lines
>      (match (primitive-fork)

Unfortunately, this doesn't quite work.  I tried this patch:

=2D-8<---------------cut here---------------start------------->8---
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 510cee727f..4399a5dd04 100644
=2D-- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -420,7 +420,7 @@ (define script
     ;; Script to obtain the list of environment variable values.  On a POS=
IX
     ;; shell we can rely on 'set', but on fish we have to use 'env' (fish's
     ;; 'set' truncates values and prints them in a different format.)
=2D    "env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
+    "PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exi=
t\n")
=20
   (define lines
     (match (primitive-fork)
@@ -440,7 +440,7 @@ (define lines
               (result (begin
                         (display script port)
                         (let loop ((lines '()))
=2D                          (match (read-line port)
+                          (match (pk 'read-line (read-line port))
                             ((? eof-object?) (reverse lines))
                             ("GUIX-CHECK-DONE\r"
                              (display "done\n" port)
@@ -458,10 +458,10 @@ (define lines
           ;; but it also truncates values anyway, so don't try to support =
it.
           (let ((index (string-index line #\=3D)))
             (if index
=2D                (vhash-cons (string-take line index)
+                (vhash-cons (pk 'variable line (string-take line index))
                             (string-drop line (+ 1 index))
                             table)
=2D                table)))
+                (pk 'dropped line table))))
         vlist-null
         lines))
=2D-8<---------------cut here---------------end--------------->8---

Here is the output:

=2D-8<---------------cut here---------------start------------->8---
[0] [env] marusich@suzaku:~/guix-master
$ ./pre-inst-env guix shell --check --pure --development guix
guix shell: checking the environment variables visible from shell '/bin/bas=
h'...

;;; (read-line "PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; r=
ead x; exit\r")

;;; (read-line "\x1b[?2004h[0] [env] marusich@suzaku:~/guix-master\r\r")

;;; (read-line "$ PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE;=
 read x; exit\r")

;;; (read-line "\x1b[?2004l\rPKG_CONFIG_PATH=3D/gnu/store/hvcq6yjfjjc7060pq=
09zm1rj02mivg4h-profile/lib/pkgconfig\r")

;;; (read-line "PWD=3D/home/marusich/guix-master\r")

;;; (read-line "LOGNAME=3Dmarusich\r")

;;; (read-line "GUILE_LOAD_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg=
4h-profile/share/guile/site/3.0\r")

;;; (read-line "HOME=3D/home/marusich\r")

;;; (read-line "LS_COLORS=3Drs=3D0:di=3D01;34:ln=3D01;36:mh=3D00:pi=3D40;33=
:so=3D01;35:do=3D01;35:bd=3D40;33;01:cd=3D40;33;01:or=3D40;31;01:mi=3D00:su=
=3D37;41:sg=3D30;43:ca=3D30;41:tw=3D30;42:ow=3D34;42:st=3D37;44:ex=3D01;32:=
*.tar=3D01;31:*.tgz=3D01;31:*.arc=3D01;31:*.arj=3D01;31:*.taz=3D01;31:*.lha=
=3D01;31:*.lz4=3D01;31:*.lzh=3D01;31:*.lzma=3D01;31:*.tlz=3D01;31:*.txz=3D0=
1;31:*.tzo=3D01;31:*.t7z=3D01;31:*.zip=3D01;31:*.z=3D01;31:*.dz=3D01;31:*.g=
z=3D01;31:*.lrz=3D01;31:*.lz=3D01;31:*.lzo=3D01;31:*.xz=3D01;31:*.zst=3D01;=
31:*.tzst=3D01;31:*.bz2=3D01;31:*.bz=3D01;31:*.tbz=3D01;31:*.tbz2=3D01;31:*=
.tz=3D01;31:*.deb=3D01;31:*.rpm=3D01;31:*.jar=3D01;31:*.war=3D01;31:*.ear=
=3D01;31:*.sar=3D01;31:*.rar=3D01;31:*.alz=3D01;31:*.ace=3D01;31:*.zoo=3D01=
;31:*.cpio=3D01;31:*.7z=3D01;31:*.rz=3D01;31:*.cab=3D01;31:*.wim=3D01;31:*.=
swm=3D01;31:*.dwm=3D01;31:*.esd=3D01;31:*.jpg=3D01;35:*.jpeg=3D01;35:*.mjpg=
=3D01;35:*.mjpeg=3D01;35:*.gif=3D01;35:*.bmp=3D01;35:*.pbm=3D01;35:*.pgm=3D=
01;35:*.ppm=3D01;35:*.tga=3D01;35:*.xbm=3D01;35:*.xpm=3D01;35:*.tif=3D01;35=
:*.tiff=3D01;35:*.png=3D01;35:*.svg=3D01;35:*.svgz=3D01;35:*.mng=3D01;35:*.=
pcx=3D01;35:*.mov=3D01;35:*.mpg=3D01;35:*.mpeg=3D01;35:*.m2v=3D01;35:*.mkv=
=3D01;35:*.webm=3D01;35:*.webp=3D01;35:*.ogm=3D01;35:*.mp4=3D01;35:*.m4v=3D=
01;35:*.mp4v=3D01;35:*.vob=3D01;35:*.qt=3D01;35:*.nuv=3D01;35:*.wmv=3D01;35=
:*.asf=3D01;35:*.rm=3D01;35:*.rmvb=3D01;35:*.flc=3D01;35:*.avi=3D01;35:*.fl=
i=3D01;35:*.flv=3D01;35:*.gl=3D01;35:*.dl=3D01;35:*.xcf=3D01;35:*.xwd=3D01;=
35:*.yuv=3D01;35:*.cgm=3D01;35:*.emf=3D01;35:*.ogv=3D01;35:*.ogx=3D01;35:*.=
aac=3D00;36:*.au=3D00;36:*.flac=3D00;36:*.m4a=3D00;36:*.mid=3D00;36:*.midi=
=3D00;36:*.mka=3D00;36:*.mp3=3D00;36:*.mpc=3D00;36:*.ogg=3D00;36:*.ra=3D00;=
36:*.wav=3D00;36:*.oga=3D00;36:*.opus=3D00;36:*.spx=3D00;36:*.xspf=3D00;36:=
\r")

;;; (read-line "GUILE_LOAD_COMPILED_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm=
1rj02mivg4h-profile/lib/guile/3.0/site-ccache:/gnu/store/hvcq6yjfjjc7060pq0=
9zm1rj02mivg4h-profile/share/guile/site/3.0\r")

;;; (read-line "INFOPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-prof=
ile/share/info\r")

;;; (read-line "TERM=3Dscreen.xterm-256color\r")

;;; (read-line "CPLUS_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02m=
ivg4h-profile/include/c++:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profi=
le/include\r")

;;; (read-line "ACLOCAL_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-=
profile/share/aclocal\r")

;;; (read-line "USER=3Dmarusich\r")

;;; (read-line "LIBRARY_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-=
profile/lib\r")

;;; (read-line "SHLVL=3D1\r")

;;; (read-line "GUIX_LOCPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-=
profile/lib/locale\r")

;;; (read-line "GUIX_ENVIRONMENT=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02miv=
g4h-profile\r")

;;; (read-line "PS1=3D\r")

;;; (read-line "PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/=
bin:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/sbin\r")

;;; (read-line "C_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4=
h-profile/include\r")

;;; (read-line "_=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/bin=
/env\r")

;;; (read-line "GUIX-CHECK-DONE\r")

;;; (variable "PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; re=
ad x; exit" "PS1")

;;; (dropped "\x1b[?2004h[0] [env] marusich@suzaku:~/guix-master\r" #<vhash=
 2b482ca0 1 pairs>)

;;; (variable "$ PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; =
read x; exit" "$ PS1")

;;; (variable "\x1b[?2004l\rPKG_CONFIG_PATH=3D/gnu/store/hvcq6yjfjjc7060pq0=
9zm1rj02mivg4h-profile/lib/pkgconfig" "\x1b[?2004l\rPKG_CONFIG_PATH")

;;; (variable "PWD=3D/home/marusich/guix-master" "PWD")

;;; (variable "LOGNAME=3Dmarusich" "LOGNAME")

;;; (variable "GUILE_LOAD_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4=
h-profile/share/guile/site/3.0" "GUILE_LOAD_PATH")

;;; (variable "HOME=3D/home/marusich" "HOME")

;;; (variable "LS_COLORS=3Drs=3D0:di=3D01;34:ln=3D01;36:mh=3D00:pi=3D40;33:=
so=3D01;35:do=3D01;35:bd=3D40;33;01:cd=3D40;33;01:or=3D40;31;01:mi=3D00:su=
=3D37;41:sg=3D30;43:ca=3D30;41:tw=3D30;42:ow=3D34;42:st=3D37;44:ex=3D01;32:=
*.tar=3D01;31:*.tgz=3D01;31:*.arc=3D01;31:*.arj=3D01;31:*.taz=3D01;31:*.lha=
=3D01;31:*.lz4=3D01;31:*.lzh=3D01;31:*.lzma=3D01;31:*.tlz=3D01;31:*.txz=3D0=
1;31:*.tzo=3D01;31:*.t7z=3D01;31:*.zip=3D01;31:*.z=3D01;31:*.dz=3D01;31:*.g=
z=3D01;31:*.lrz=3D01;31:*.lz=3D01;31:*.lzo=3D01;31:*.xz=3D01;31:*.zst=3D01;=
31:*.tzst=3D01;31:*.bz2=3D01;31:*.bz=3D01;31:*.tbz=3D01;31:*.tbz2=3D01;31:*=
.tz=3D01;31:*.deb=3D01;31:*.rpm=3D01;31:*.jar=3D01;31:*.war=3D01;31:*.ear=
=3D01;31:*.sar=3D01;31:*.rar=3D01;31:*.alz=3D01;31:*.ace=3D01;31:*.zoo=3D01=
;31:*.cpio=3D01;31:*.7z=3D01;31:*.rz=3D01;31:*.cab=3D01;31:*.wim=3D01;31:*.=
swm=3D01;31:*.dwm=3D01;31:*.esd=3D01;31:*.jpg=3D01;35:*.jpeg=3D01;35:*.mjpg=
=3D01;35:*.mjpeg=3D01;35:*.gif=3D01;35:*.bmp=3D01;35:*.pbm=3D01;35:*.pgm=3D=
01;35:*.ppm=3D01;35:*.tga=3D01;35:*.xbm=3D01;35:*.xpm=3D01;35:*.tif=3D01;35=
:*.tiff=3D01;35:*.png=3D01;35:*.svg=3D01;35:*.svgz=3D01;35:*.mng=3D01;35:*.=
pcx=3D01;35:*.mov=3D01;35:*.mpg=3D01;35:*.mpeg=3D01;35:*.m2v=3D01;35:*.mkv=
=3D01;35:*.webm=3D01;35:*.webp=3D01;35:*.ogm=3D01;35:*.mp4=3D01;35:*.m4v=3D=
01;35:*.mp4v=3D01;35:*.vob=3D01;35:*.qt=3D01;35:*.nuv=3D01;35:*.wmv=3D01;35=
:*.asf=3D01;35:*.rm=3D01;35:*.rmvb=3D01;35:*.flc=3D01;35:*.avi=3D01;35:*.fl=
i=3D01;35:*.flv=3D01;35:*.gl=3D01;35:*.dl=3D01;35:*.xcf=3D01;35:*.xwd=3D01;=
35:*.yuv=3D01;35:*.cgm=3D01;35:*.emf=3D01;35:*.ogv=3D01;35:*.ogx=3D01;35:*.=
aac=3D00;36:*.au=3D00;36:*.flac=3D00;36:*.m4a=3D00;36:*.mid=3D00;36:*.midi=
=3D00;36:*.mka=3D00;36:*.mp3=3D00;36:*.mpc=3D00;36:*.ogg=3D00;36:*.ra=3D00;=
36:*.wav=3D00;36:*.oga=3D00;36:*.opus=3D00;36:*.spx=3D00;36:*.xspf=3D00;36:=
" "LS_COLORS")

;;; (variable "GUILE_LOAD_COMPILED_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1=
rj02mivg4h-profile/lib/guile/3.0/site-ccache:/gnu/store/hvcq6yjfjjc7060pq09=
zm1rj02mivg4h-profile/share/guile/site/3.0" "GUILE_LOAD_COMPILED_PATH")

;;; (variable "INFOPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profi=
le/share/info" "INFOPATH")

;;; (variable "TERM=3Dscreen.xterm-256color" "TERM")

;;; (variable "CPLUS_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mi=
vg4h-profile/include/c++:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profil=
e/include" "CPLUS_INCLUDE_PATH")

;;; (variable "ACLOCAL_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-p=
rofile/share/aclocal" "ACLOCAL_PATH")

;;; (variable "USER=3Dmarusich" "USER")

;;; (variable "LIBRARY_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-p=
rofile/lib" "LIBRARY_PATH")

;;; (variable "SHLVL=3D1" "SHLVL")

;;; (variable "GUIX_LOCPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-p=
rofile/lib/locale" "GUIX_LOCPATH")

;;; (variable "GUIX_ENVIRONMENT=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg=
4h-profile" "GUIX_ENVIRONMENT")

;;; (variable "PS1=3D" "PS1")

;;; (variable "PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/b=
in:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/sbin" "PATH")

;;; (variable "C_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h=
-profile/include" "C_INCLUDE_PATH")

;;; (variable "_=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/bin/=
env" "_")
guix shell: warning: variable 'PKG_CONFIG_PATH' is missing from shell envir=
onment
hint: One or more environment variables have a different value in the shell=
 than
the one we set.  This means that you may find yourself running code in an
environment different from the one you asked Guix to prepare.

This usually indicates that your shell startup files are unexpectedly
modifying those environment variables.  For example, if you are using Bash,
make sure that environment variables are set or modified in
`~/.bash_profile' and _not_ in `~/.bashrc'.  For more information on Bash
startup files, run:

     info "(bash) Bash Startup Files"

Alternatively, you can avoid the problem by passing the `--container' or
`-C' option.  That will give you a fully isolated environment running in a
"container", immune to the issue described above.

[1] [env] marusich@suzaku:~/guix-master
$=20
=2D-8<---------------cut here---------------end--------------->8---

Most of the interesting stuff happened in the first few lines:

=2D-8<---------------cut here---------------start------------->8---
;;; (read-line "PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; r=
ead x; exit\r")

;;; (read-line "\x1b[?2004h[0] [env] marusich@suzaku:~/guix-master\r\r")

;;; (read-line "$ PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE;=
 read x; exit\r")

;;; (read-line "\x1b[?2004l\rPKG_CONFIG_PATH=3D/gnu/store/hvcq6yjfjjc7060pq=
09zm1rj02mivg4h-profile/lib/pkgconfig\r")
=2D-8<---------------cut here---------------end--------------->8---

As you can see, nothing good is happening when the code parses this
later on:

=2D-8<---------------cut here---------------start------------->8---
;;; (variable "PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; re=
ad x; exit" "PS1")

;;; (dropped "\x1b[?2004h[0] [env] marusich@suzaku:~/guix-master\r" #<vhash=
 2b482ca0 1 pairs>)

;;; (variable "$ PS1=3D; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; =
read x; exit" "$ PS1")

;;; (variable "\x1b[?2004l\rPKG_CONFIG_PATH=3D/gnu/store/hvcq6yjfjjc7060pq0=
9zm1rj02mivg4h-profile/lib/pkgconfig" "\x1b[?2004l\rPKG_CONFIG_PATH")
=2D-8<---------------cut here---------------end--------------->8---

Although I'm sure you see it, for clarity I will explain why the above
is bad: The first variable was actually just the entire script being
echoed back; it is not actually an environment variable.  The second
variable "$ PS1" is also not really an environment variable.  And the
variable "\x1b[?2004l\rPKG_CONFIG_PATH", again, appears to contain
garbage at the start, probably from my PS1 value.

Basically, I think we can work around these issues if we just read and
discard all that junk at the start.  I wasn't able to figure out a
graceful way to force that to happen, but I did find that simply
printing a few lines at the start of the script was good enough to work
around the issue on my computer.  Here's my proposed patch, with
debugging statements included:

=2D-8<---------------cut here---------------start------------->8---
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 510cee727f..35669b39cd 100644
=2D-- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -420,7 +420,8 @@ (define script
     ;; Script to obtain the list of environment variable values.  On a POS=
IX
     ;; shell we can rely on 'set', but on fish we have to use 'env' (fish's
     ;; 'set' truncates values and prints them in a different format.)
=2D    "env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
+    "PS1=3D; for i in 1 2 3; do echo GUIX_FLUSH_$i; done; \
+env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
=20
   (define lines
     (match (primitive-fork)
@@ -439,8 +440,10 @@ (define lines
        (let* ((port   (fdopen controller "r+l"))
               (result (begin
                         (display script port)
+                        (while (not (string=3D? "GUIX_FLUSH_3\r"
+                                              (read-line port))))
                         (let loop ((lines '()))
=2D                          (match (read-line port)
+                          (match (pk 'read-line (read-line port))
                             ((? eof-object?) (reverse lines))
                             ("GUIX-CHECK-DONE\r"
                              (display "done\n" port)
@@ -458,10 +461,10 @@ (define lines
           ;; but it also truncates values anyway, so don't try to support =
it.
           (let ((index (string-index line #\=3D)))
             (if index
=2D                (vhash-cons (string-take line index)
+                (vhash-cons (pk 'variable line (string-take line index))
                             (string-drop line (+ 1 index))
                             table)
=2D                table)))
+                (pk 'dropped line table))))
         vlist-null
         lines))
=20
=2D-8<---------------cut here---------------end--------------->8---

And here's the output:

=2D-8<---------------cut here---------------start------------->8---
[0] [env] marusich@suzaku:~/guix-master
$ ./pre-inst-env guix shell --check --pure --development guix
guix shell: checking the environment variables visible from shell '/bin/bas=
h'...

;;; (read-line "PKG_CONFIG_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg=
4h-profile/lib/pkgconfig\r")

;;; (read-line "PWD=3D/home/marusich/guix-master\r")

;;; (read-line "LOGNAME=3Dmarusich\r")

;;; (read-line "GUILE_LOAD_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg=
4h-profile/share/guile/site/3.0\r")

;;; (read-line "HOME=3D/home/marusich\r")

;;; (read-line "LS_COLORS=3Drs=3D0:di=3D01;34:ln=3D01;36:mh=3D00:pi=3D40;33=
:so=3D01;35:do=3D01;35:bd=3D40;33;01:cd=3D40;33;01:or=3D40;31;01:mi=3D00:su=
=3D37;41:sg=3D30;43:ca=3D30;41:tw=3D30;42:ow=3D34;42:st=3D37;44:ex=3D01;32:=
*.tar=3D01;31:*.tgz=3D01;31:*.arc=3D01;31:*.arj=3D01;31:*.taz=3D01;31:*.lha=
=3D01;31:*.lz4=3D01;31:*.lzh=3D01;31:*.lzma=3D01;31:*.tlz=3D01;31:*.txz=3D0=
1;31:*.tzo=3D01;31:*.t7z=3D01;31:*.zip=3D01;31:*.z=3D01;31:*.dz=3D01;31:*.g=
z=3D01;31:*.lrz=3D01;31:*.lz=3D01;31:*.lzo=3D01;31:*.xz=3D01;31:*.zst=3D01;=
31:*.tzst=3D01;31:*.bz2=3D01;31:*.bz=3D01;31:*.tbz=3D01;31:*.tbz2=3D01;31:*=
.tz=3D01;31:*.deb=3D01;31:*.rpm=3D01;31:*.jar=3D01;31:*.war=3D01;31:*.ear=
=3D01;31:*.sar=3D01;31:*.rar=3D01;31:*.alz=3D01;31:*.ace=3D01;31:*.zoo=3D01=
;31:*.cpio=3D01;31:*.7z=3D01;31:*.rz=3D01;31:*.cab=3D01;31:*.wim=3D01;31:*.=
swm=3D01;31:*.dwm=3D01;31:*.esd=3D01;31:*.jpg=3D01;35:*.jpeg=3D01;35:*.mjpg=
=3D01;35:*.mjpeg=3D01;35:*.gif=3D01;35:*.bmp=3D01;35:*.pbm=3D01;35:*.pgm=3D=
01;35:*.ppm=3D01;35:*.tga=3D01;35:*.xbm=3D01;35:*.xpm=3D01;35:*.tif=3D01;35=
:*.tiff=3D01;35:*.png=3D01;35:*.svg=3D01;35:*.svgz=3D01;35:*.mng=3D01;35:*.=
pcx=3D01;35:*.mov=3D01;35:*.mpg=3D01;35:*.mpeg=3D01;35:*.m2v=3D01;35:*.mkv=
=3D01;35:*.webm=3D01;35:*.webp=3D01;35:*.ogm=3D01;35:*.mp4=3D01;35:*.m4v=3D=
01;35:*.mp4v=3D01;35:*.vob=3D01;35:*.qt=3D01;35:*.nuv=3D01;35:*.wmv=3D01;35=
:*.asf=3D01;35:*.rm=3D01;35:*.rmvb=3D01;35:*.flc=3D01;35:*.avi=3D01;35:*.fl=
i=3D01;35:*.flv=3D01;35:*.gl=3D01;35:*.dl=3D01;35:*.xcf=3D01;35:*.xwd=3D01;=
35:*.yuv=3D01;35:*.cgm=3D01;35:*.emf=3D01;35:*.ogv=3D01;35:*.ogx=3D01;35:*.=
aac=3D00;36:*.au=3D00;36:*.flac=3D00;36:*.m4a=3D00;36:*.mid=3D00;36:*.midi=
=3D00;36:*.mka=3D00;36:*.mp3=3D00;36:*.mpc=3D00;36:*.ogg=3D00;36:*.ra=3D00;=
36:*.wav=3D00;36:*.oga=3D00;36:*.opus=3D00;36:*.spx=3D00;36:*.xspf=3D00;36:=
\r")

;;; (read-line "GUILE_LOAD_COMPILED_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm=
1rj02mivg4h-profile/lib/guile/3.0/site-ccache:/gnu/store/hvcq6yjfjjc7060pq0=
9zm1rj02mivg4h-profile/share/guile/site/3.0\r")

;;; (read-line "INFOPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-prof=
ile/share/info\r")

;;; (read-line "TERM=3Dscreen.xterm-256color\r")

;;; (read-line "CPLUS_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02m=
ivg4h-profile/include/c++:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profi=
le/include\r")

;;; (read-line "ACLOCAL_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-=
profile/share/aclocal\r")

;;; (read-line "USER=3Dmarusich\r")

;;; (read-line "LIBRARY_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-=
profile/lib\r")

;;; (read-line "SHLVL=3D1\r")

;;; (read-line "GUIX_LOCPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-=
profile/lib/locale\r")

;;; (read-line "GUIX_ENVIRONMENT=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02miv=
g4h-profile\r")

;;; (read-line "PS1=3D\r")

;;; (read-line "PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/=
bin:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/sbin\r")

;;; (read-line "C_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4=
h-profile/include\r")

;;; (read-line "_=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/bin=
/env\r")

;;; (read-line "GUIX-CHECK-DONE\r")

;;; (variable "PKG_CONFIG_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4=
h-profile/lib/pkgconfig" "PKG_CONFIG_PATH")

;;; (variable "PWD=3D/home/marusich/guix-master" "PWD")

;;; (variable "LOGNAME=3Dmarusich" "LOGNAME")

;;; (variable "GUILE_LOAD_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4=
h-profile/share/guile/site/3.0" "GUILE_LOAD_PATH")

;;; (variable "HOME=3D/home/marusich" "HOME")

;;; (variable "LS_COLORS=3Drs=3D0:di=3D01;34:ln=3D01;36:mh=3D00:pi=3D40;33:=
so=3D01;35:do=3D01;35:bd=3D40;33;01:cd=3D40;33;01:or=3D40;31;01:mi=3D00:su=
=3D37;41:sg=3D30;43:ca=3D30;41:tw=3D30;42:ow=3D34;42:st=3D37;44:ex=3D01;32:=
*.tar=3D01;31:*.tgz=3D01;31:*.arc=3D01;31:*.arj=3D01;31:*.taz=3D01;31:*.lha=
=3D01;31:*.lz4=3D01;31:*.lzh=3D01;31:*.lzma=3D01;31:*.tlz=3D01;31:*.txz=3D0=
1;31:*.tzo=3D01;31:*.t7z=3D01;31:*.zip=3D01;31:*.z=3D01;31:*.dz=3D01;31:*.g=
z=3D01;31:*.lrz=3D01;31:*.lz=3D01;31:*.lzo=3D01;31:*.xz=3D01;31:*.zst=3D01;=
31:*.tzst=3D01;31:*.bz2=3D01;31:*.bz=3D01;31:*.tbz=3D01;31:*.tbz2=3D01;31:*=
.tz=3D01;31:*.deb=3D01;31:*.rpm=3D01;31:*.jar=3D01;31:*.war=3D01;31:*.ear=
=3D01;31:*.sar=3D01;31:*.rar=3D01;31:*.alz=3D01;31:*.ace=3D01;31:*.zoo=3D01=
;31:*.cpio=3D01;31:*.7z=3D01;31:*.rz=3D01;31:*.cab=3D01;31:*.wim=3D01;31:*.=
swm=3D01;31:*.dwm=3D01;31:*.esd=3D01;31:*.jpg=3D01;35:*.jpeg=3D01;35:*.mjpg=
=3D01;35:*.mjpeg=3D01;35:*.gif=3D01;35:*.bmp=3D01;35:*.pbm=3D01;35:*.pgm=3D=
01;35:*.ppm=3D01;35:*.tga=3D01;35:*.xbm=3D01;35:*.xpm=3D01;35:*.tif=3D01;35=
:*.tiff=3D01;35:*.png=3D01;35:*.svg=3D01;35:*.svgz=3D01;35:*.mng=3D01;35:*.=
pcx=3D01;35:*.mov=3D01;35:*.mpg=3D01;35:*.mpeg=3D01;35:*.m2v=3D01;35:*.mkv=
=3D01;35:*.webm=3D01;35:*.webp=3D01;35:*.ogm=3D01;35:*.mp4=3D01;35:*.m4v=3D=
01;35:*.mp4v=3D01;35:*.vob=3D01;35:*.qt=3D01;35:*.nuv=3D01;35:*.wmv=3D01;35=
:*.asf=3D01;35:*.rm=3D01;35:*.rmvb=3D01;35:*.flc=3D01;35:*.avi=3D01;35:*.fl=
i=3D01;35:*.flv=3D01;35:*.gl=3D01;35:*.dl=3D01;35:*.xcf=3D01;35:*.xwd=3D01;=
35:*.yuv=3D01;35:*.cgm=3D01;35:*.emf=3D01;35:*.ogv=3D01;35:*.ogx=3D01;35:*.=
aac=3D00;36:*.au=3D00;36:*.flac=3D00;36:*.m4a=3D00;36:*.mid=3D00;36:*.midi=
=3D00;36:*.mka=3D00;36:*.mp3=3D00;36:*.mpc=3D00;36:*.ogg=3D00;36:*.ra=3D00;=
36:*.wav=3D00;36:*.oga=3D00;36:*.opus=3D00;36:*.spx=3D00;36:*.xspf=3D00;36:=
" "LS_COLORS")

;;; (variable "GUILE_LOAD_COMPILED_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1=
rj02mivg4h-profile/lib/guile/3.0/site-ccache:/gnu/store/hvcq6yjfjjc7060pq09=
zm1rj02mivg4h-profile/share/guile/site/3.0" "GUILE_LOAD_COMPILED_PATH")

;;; (variable "INFOPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profi=
le/share/info" "INFOPATH")

;;; (variable "TERM=3Dscreen.xterm-256color" "TERM")

;;; (variable "CPLUS_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mi=
vg4h-profile/include/c++:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profil=
e/include" "CPLUS_INCLUDE_PATH")

;;; (variable "ACLOCAL_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-p=
rofile/share/aclocal" "ACLOCAL_PATH")

;;; (variable "USER=3Dmarusich" "USER")

;;; (variable "LIBRARY_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-p=
rofile/lib" "LIBRARY_PATH")

;;; (variable "SHLVL=3D1" "SHLVL")

;;; (variable "GUIX_LOCPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-p=
rofile/lib/locale" "GUIX_LOCPATH")

;;; (variable "GUIX_ENVIRONMENT=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg=
4h-profile" "GUIX_ENVIRONMENT")

;;; (variable "PS1=3D" "PS1")

;;; (variable "PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/b=
in:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/sbin" "PATH")

;;; (variable "C_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h=
-profile/include" "C_INCLUDE_PATH")

;;; (variable "_=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/bin/=
env" "_")
guix shell: All is good!  The shell gets correct environment variables.
[0] [env] marusich@suzaku:~/guix-master
$=20
=2D-8<---------------cut here---------------end--------------->8---

As you can see, it seems to be working correctly here.

Here's a version of the patch that is ready for committing, with the
debug statements removed and comments added:


--=-=-=
Content-Type: text/x-patch; charset=utf-8
Content-Disposition: inline;
 filename=0001-environment-Prevent-PS1-from-clobbering-output-in-ch.patch
Content-Transfer-Encoding: quoted-printable
Content-Description: [PATCH] environment: Prevent PS1 from clobbering output in 'check'.

From=20c3eea81846ae71a246e6b592be74062f4bf26474 Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@HIDDEN>
Date: Sun, 13 Feb 2022 14:15:14 -0800
Subject: [PATCH] environment: Prevent PS1 from clobbering output in 'check'.

Fixes: <https://issues.guix.gnu.org/51466>.

* guix/scripts/environment.scm (child-shell-environment): In the script
executed the child shell, set PS1 to an empty value and then echo three
sentinel lines to try to "flush" the original PS1 value before printing the
environment variables.  In the parent process, read and discard all lines up
to and including the last sentinel line.  After that, read the remaining li=
nes
as usual.
=2D--
 guix/scripts/environment.scm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index ec071402f4..0b137467f9 100644
=2D-- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -2,6 +2,7 @@
 ;;; Copyright =C2=A9 2014, 2015, 2018 David Thompson <davet@HIDDEN>
 ;;; Copyright =C2=A9 2015-2022 Ludovic Court=C3=A8s <ludo@HIDDEN>
 ;;; Copyright =C2=A9 2018 Mike Gerwitz <mtg@HIDDEN>
+;;; Copyright =C2=A9 2022 Chris Marusich <cmmarusich@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -420,7 +421,16 @@ by running 'set' in the shell."
     ;; Script to obtain the list of environment variable values.  On a POS=
IX
     ;; shell we can rely on 'set', but on fish we have to use 'env' (fish's
     ;; 'set' truncates values and prints them in a different format.)
=2D    "env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
+    ;;
+    ;; Why print "GUIX_FLUSH" a few times?  We are trying to "flush" the
+    ;; original PS1 value to the port so we can read it (and discard it)
+    ;; before we start reading the environment variables from the port.  I=
f we
+    ;; don't do this, the original PS1 value can sometimes get interleaved
+    ;; into the output, which interferes with our parsing logic.  It's a h=
ack,
+    ;; but in practice it seems to do the job.  If you know of a more grac=
eful
+    ;; solution, please implement it!  See: https://issues.guix.gnu.org/51=
466
+    "PS1=3D; for i in 1 2 3; do echo GUIX_FLUSH_$i; done; \
+env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
=20
   (define lines
     (match (primitive-fork)
@@ -439,6 +449,12 @@ by running 'set' in the shell."
        (let* ((port   (fdopen controller "r+l"))
               (result (begin
                         (display script port)
+                        ;; Ignore all lines up to and including the final
+                        ;; "GUIX_FLUSH" line.
+                        (while (not (string=3D? "GUIX_FLUSH_3\r"
+                                              (read-line port))))
+                        ;; Now (hopefully) the original PS1 value will not=
 be
+                        ;; interleaved in the remaining lines.
                         (let loop ((lines '()))
                           (match (read-line port)
                             ((? eof-object?) (reverse lines))

base-commit: d65979c46c99dc36324ca94aa9650b9de37f22de
=2D-=20
2.26.3


--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable


And here's its output:

=2D-8<---------------cut here---------------start------------->8---
[0] [env] marusich@suzaku:~/guix-master
$ ./pre-inst-env guix shell --check --pure --development guix
guix shell: checking the environment variables visible from shell '/bin/bas=
h'...
guix shell: All is good!  The shell gets correct environment variables.
[0] [env] marusich@suzaku:~/guix-master
$=20
=2D-8<---------------cut here---------------end--------------->8---

WDYT?

=2D-=20
Chris

PGP: https://savannah.gnu.org/people/viewgpg.php?user_id=3D106836

--=-=-=--

--==-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAmIJkYAVHGNtbWFydXNp
Y2hAZ21haWwuY29tAAoJEN1AmhXYIkad/DIP/0cK4RtFfWrzLm87ZjPnWDKVkUN8
12GYm6uWgFAImqcmS8ZH9lep6o6lhyJSYqQ1Vpv15XdUrg5o7jwQlCWU595JaWZH
AxwhAjZA2rOaibtftiuKJN7awJUoSt+XJpYWEJVoajz0DS7hh6HVMLbmf441S+HB
fX5eY7JPQSbJk9o0owXyZB3KkGl5fkwy2XNLnPqUXIH+bcU3xL4CO2qH3EUzmFKN
K5UVSo7IzyVBj6DH0w3CQWxTioQxfdZJvy9W5qK4DPx4r+c+teEnGqoHm0RO0e6x
r5Woy5v0bC3rOSrT1jxcQW7S4ClzxmTbPfwVyvPN09IB1fTabGoqBVAFDTdn0tCv
K3OQnTK+0PwSMdlcVX3QvZGSByylTu/AqMM7UFgt+kd867Og5hOHHWRdHfm1t9Lv
61BGcS6tg0qTSQZbwCcilBHWm5ZhnJyLD6BL3c7gzvPt6I+UyM3XdBARHOyUMoVB
DrZ9T5jh+RGw65oRnDLnIQdYCZk7cS3dZ5YFH+5xrpNf7kltdCPGZnNT+mORsGxJ
tqiEhZF+XF2aoaGiP7FdK2gl/p2A4A3Ouoo0uoStWjal0WhVD0oE7GNueC/nqnst
y36MQBnU0IX5BXZF9uPxPklRFhMc1XkAGo3o1mxD5Oczua/0Mrg+A1svi8oaFVaz
S1G97WFENNuMlvNL
=CTxU
-----END PGP SIGNATURE-----
--==-=-=--




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 8 Feb 2022 09:26:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 08 04:26:38 2022
Received: from localhost ([127.0.0.1]:45299 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nHMla-00026O-HE
	for submit <at> debbugs.gnu.org; Tue, 08 Feb 2022 04:26:38 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:35028)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1nHMlY-00026A-TH
 for 51466 <at> debbugs.gnu.org; Tue, 08 Feb 2022 04:26:29 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 92AAE361;
 Tue,  8 Feb 2022 10:26:22 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id affheNiImK3S; Tue,  8 Feb 2022 10:26:21 +0100 (CET)
Received: from ribbon (unknown [193.50.110.192])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 9D029132;
 Tue,  8 Feb 2022 10:26:21 +0100 (CET)
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Chris Marusich <cmmarusich@HIDDEN>
Subject: Re: bug#53355: guix shell --check: confusing error message
References: <87h7a08kub.fsf@HIDDEN> <87lez5td4n.fsf@HIDDEN>
 <87sftc4osu.fsf@HIDDEN> <87h79slysd.fsf@HIDDEN>
 <87sft13dyv.fsf@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 20 =?utf-8?Q?Pluvi=C3=B4se?= an 230 de la
 =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Tue, 08 Feb 2022 10:26:21 +0100
In-Reply-To: <87sft13dyv.fsf@HIDDEN> (Chris Marusich's message of "Tue, 01
 Feb 2022 23:49:28 -0800")
Message-ID: <874k59d802.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 92AAE361
X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[];
 RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[];
 TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com];
 TO_MATCH_ENVRCPT_ALL(0.00)[];
 MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch];
 RCPT_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[gmail.com];
 FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+];
 RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[];
 MID_RHS_MATCH_FROM(0.00)[]
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 51466
Cc: 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--=-=-=
Content-Type: text/plain

Hi Chris,

Thanks for testing!

Chris Marusich <cmmarusich@HIDDEN> skribis:

> The presence of the "$" in front of LIBRARY_PATH seems suspicious:
>
>   ;;; (variable "$ LIBRARY_PATH=/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/lib" "$ LIBRARY_PATH")
>
> I'm not sure why the "$" is being added.  I tried various things to
> remove it.  I tried explicitly setting PS1 to an empty string in my
> ~/.bashrc.  I also tried setting it explicitly to an empty string in
> /etc/profile.  Maybe if we can figure out where that "$ " prefix is
> coming from, we can resolve this issue?

How about this:


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index ec071402f4..ac2c79ab65 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -420,7 +420,7 @@ (define script
     ;; Script to obtain the list of environment variable values.  On a POSIX
     ;; shell we can rely on 'set', but on fish we have to use 'env' (fish's
     ;; 'set' truncates values and prints them in a different format.)
-    "env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
+    "PS1=; env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit\n")
 
   (define lines
     (match (primitive-fork)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable


?

Thanks,
Ludo=E2=80=99.

--=-=-=--




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 2 Feb 2022 07:49:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 02 02:49:40 2022
Received: from localhost ([127.0.0.1]:51321 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nFAOa-0001nq-GY
	for submit <at> debbugs.gnu.org; Wed, 02 Feb 2022 02:49:40 -0500
Received: from mail-pj1-f54.google.com ([209.85.216.54]:40572)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <cmmarusich@HIDDEN>) id 1nFAOZ-0001nZ-0Q
 for 51466 <at> debbugs.gnu.org; Wed, 02 Feb 2022 02:49:39 -0500
Received: by mail-pj1-f54.google.com with SMTP id
 z10-20020a17090acb0a00b001b520826011so5999922pjt.5
 for <51466 <at> debbugs.gnu.org>; Tue, 01 Feb 2022 23:49:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=Ag48wvr7nOjPGfUSXOJcHP5/2pRlSxCVXL7fbpOSRTE=;
 b=Dm0CiJMufRTzjvyC1t70M+uRq8aF4yM0vwJ86yDhHUnSSy7qy2gtx7F14xY+M4xTMm
 utvO1aals2l35J+KBBCa0euAkgAYBxHRI+hjOFTdiq0f5EKTgAF077+/0NBEmgwiSo/W
 +abQiedoaxSb2gOGO3qMA8VGvrwiUiYRyknPnJykQQD4cuEGqqUwciqj+CLrvLUXs+8t
 iGPTvSEer8rRL3DXbaSsOGDIYeUaERLq0hZcj6MnVuVMXX4MNCj3O2ckiw+Hu4EoXEoJ
 pMHGXGOMf29fTZERKLJwQEfSdxwT+axbpXvmUmBT+uBqzjdm718VzrtGrq96rnFlKMzS
 ZilQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=Ag48wvr7nOjPGfUSXOJcHP5/2pRlSxCVXL7fbpOSRTE=;
 b=PLgRI9BsIXJwgvg8o4+gGPqxPajEBrAQTV28o/DHnFBFv44jDTFu+Q5Fg9E+8O6nAD
 fo9L6AUpkzyEDFeRJRTd6o+pjm52eF+GBzR2KcK9ED71Uha64jUc74kCNsr/X4nos5ez
 1s+jPR4+dVLI6VQfz/5rj+wpUG6w8jk5rz10Sg6MJAAECwtYlz/k/ZS/RFlSBTArzCzO
 GuRBnlO1BoeOWyKEs3rV4vjijc2S+SN+mxIWqvhvrbXmiv+dhSUG1pcL6Hd2R/fiDcrH
 JSY8zudmJ1B/k3T0GHaIGy7GEtrzAEl6nMy1IwbNncTrvDaat4wNY/zS7frvQkG9TyHD
 nYmg==
X-Gm-Message-State: AOAM530XFjBIjOuRu+Zdq+UcYgh1YZMoS3PXBEd3DzmkZ3AYhDqWQctS
 UOqQRnPam40ImNurbRsE/2BeGDZRWJQ=
X-Google-Smtp-Source: ABdhPJw2uTyV3v3cqZB/LYg+xVxx48RotO2drm+T7aw9kG0D0fZ9s42YghV7DV5H3sBQsWrshlWXmw==
X-Received: by 2002:a17:903:2291:: with SMTP id
 b17mr28929495plh.83.1643788172238; 
 Tue, 01 Feb 2022 23:49:32 -0800 (PST)
Received: from garuda-lan (c-71-231-157-28.hsd1.wa.comcast.net.
 [71.231.157.28])
 by smtp.gmail.com with ESMTPSA id 6sm12703428pgx.36.2022.02.01.23.49.31
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 01 Feb 2022 23:49:31 -0800 (PST)
From: Chris Marusich <cmmarusich@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#53355: guix shell --check: confusing error message
References: <87h7a08kub.fsf@HIDDEN> <87lez5td4n.fsf@HIDDEN>
 <87sftc4osu.fsf@HIDDEN> <87h79slysd.fsf@HIDDEN>
Date: Tue, 01 Feb 2022 23:49:28 -0800
In-Reply-To: <87h79slysd.fsf@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?=
 =?utf-8?Q?s?= message of "Tue, 25 Jan 2022 14:39:46 +0100")
Message-ID: <87sft13dyv.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha256; protocol="application/pgp-signature"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 51466
Cc: 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi,

I also observed this bug and reported it as 53355.  I tried to search
for bugs, but I didn't find this bug report until Ludo mentioned it.  I
think it's probably the same bug, so I've merged them.

Ludovic Court=C3=A8s <ludo@HIDDEN> writes:

> It looks like the shell-check machinery is misdiagnosing things, as
> Vagrant reported in <https://issues.guix.gnu.org/51466> (is this on
> Debian too?).

Yes, it's also Debian.  Debian Bullseye.  I've also verified that
similar behavior occurs on Fedora, although the problematic env vars are
different.  I tried fiddling with SHELL like Vagrant did, but I couldn't
make the error go away like he did.  Maybe I did something differently.

> Could you try the debugging tricks I proposed there?

Sure thing!  Thank you for taking the time to make the patch, even
though it was simple.  Here is the result on my Debian Bullseye ppc64el
system:

=2D-8<---------------cut here---------------start------------->8---
[0] [env] marusich@suzaku:~/guix-master
$ ./pre-inst-env guix shell --check --pure --development guix
guix shell: checking the environment variables visible from shell '/bin/sh'=
...

;;; (dropped "env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exi=
t" #<vlist ()>)

;;; (variable "$ LIBRARY_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h=
-profile/lib" "$ LIBRARY_PATH")

;;; (variable "C_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h=
-profile/include" "C_INCLUDE_PATH")

;;; (variable "USER=3Dmarusich" "USER")

;;; (variable "GUIX_LOCPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-p=
rofile/lib/locale" "GUIX_LOCPATH")

;;; (variable "HOME=3D/home/marusich" "HOME")

;;; (variable "GUILE_LOAD_COMPILED_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1=
rj02mivg4h-profile/lib/guile/3.0/site-ccache:/gnu/store/hvcq6yjfjjc7060pq09=
zm1rj02mivg4h-profile/share/guile/site/3.0" "GUILE_LOAD_COMPILED_PATH")

;;; (variable "CPLUS_INCLUDE_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mi=
vg4h-profile/include/c++:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profil=
e/include" "CPLUS_INCLUDE_PATH")

;;; (variable "INFOPATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profi=
le/share/info" "INFOPATH")

;;; (variable "LOGNAME=3Dmarusich" "LOGNAME")

;;; (variable "PKG_CONFIG_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4=
h-profile/lib/pkgconfig" "PKG_CONFIG_PATH")

;;; (variable "TERM=3Dscreen.xterm-256color" "TERM")

;;; (variable "ACLOCAL_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-p=
rofile/share/aclocal" "ACLOCAL_PATH")

;;; (variable "PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/b=
in:/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4h-profile/sbin" "PATH")

;;; (variable "GUIX_ENVIRONMENT=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg=
4h-profile" "GUIX_ENVIRONMENT")

;;; (variable "GUILE_LOAD_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg4=
h-profile/share/guile/site/3.0" "GUILE_LOAD_PATH")

;;; (variable "PWD=3D/home/marusich/guix-master" "PWD")
guix shell: warning: variable 'LIBRARY_PATH' is missing from shell environm=
ent
hint: One or more environment variables have a different value in the shell=
 than
the one we set.  This means that you may find yourself running code in an
environment different from the one you asked Guix to prepare.

This usually indicates that your shell startup files are unexpectedly
modifying those environment variables.  For example, if you are using Bash,
make sure that environment variables are set or modified in
`~/.bash_profile' and _not_ in `~/.bashrc'.  For more information on Bash
startup files, run:

     info "(bash) Bash Startup Files"

Alternatively, you can avoid the problem by passing the `--container' or
`-C' option.  That will give you a fully isolated environment running in a
"container", immune to the issue described above.

[1] [env] marusich@suzaku:~/guix-master
$
=2D-8<---------------cut here---------------end--------------->8---

The presence of the "$" in front of LIBRARY_PATH seems suspicious:

  ;;; (variable "$ LIBRARY_PATH=3D/gnu/store/hvcq6yjfjjc7060pq09zm1rj02mivg=
4h-profile/lib" "$ LIBRARY_PATH")

I'm not sure why the "$" is being added.  I tried various things to
remove it.  I tried explicitly setting PS1 to an empty string in my
~/.bashrc.  I also tried setting it explicitly to an empty string in
/etc/profile.  Maybe if we can figure out where that "$ " prefix is
coming from, we can resolve this issue?

=2D-=20
Chris

PGP: https://savannah.gnu.org/people/viewgpg.php?user_id=3D106836

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAmH6N4gVHGNtbWFydXNp
Y2hAZ21haWwuY29tAAoJEN1AmhXYIkad+1MP/0akKpMnXNnwb16MGdmTTaP6yw5e
3BilTwLForpvYm3c9Ed1k9xOLO/v0l9Ll6i5GVD6PI8lxFeJ8Qy6isaTo3PH0tJC
jDVf+kl5PUOCIzTlewnW6aaUbDnYUY8Wo+rKGwl87yp4bOmFjXbdbEJk7Vx1jTzH
fYl59Yn4jD/pCe8CR7BOqkGOaSqFwGfYIrSlsBfkvwn12khzYk1859Q27Cbzgg0F
L2kRXmDJnrFQG5oqRK9r9LNXbP3Z5XCRiib1/AJXJv+Hbf0sgrK2kntp2fJpZ9DM
9jxU8gWKvN5rYpxzaPnKD4/Y9dr3ERuk1SBssTJMgpozERTrFl1Rh8eNYLt7BUja
78PBa4R/D+8sDwiVhog4IS9jIKV3QGbW/Em56s4NtzAwvSjn8hCP66BEYAKSCPyg
WDXgcUfu3Ut510ZyHHtChmXsG3YFjm8hfWUTdBuSM8AQqIsNh96DRo35iJEICHA+
8aexhzcoO2h1Cc9GS1APbFEWwZhKY7vy+jLeN52tJyZ10QTShcirBNKOBx9LvLFF
rgUbPWW88Bj9BLAeRaVsHrB29gNc0+PW7G5M1l2sQQ5RwlUEmFQb/vGt0CkehECJ
Dd2U9d1hiDcpk0SwPMLxNalsSE9s9oBSF1UTkp1sdwC74nim72WoBKppHc4U1Y7l
0sokQsNzd7jBakDZ
=uHkI
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.
Merged 51466 53355. Request was from Chris Marusich <cmmarusich@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Added tag(s) moreinfo. Request was from Ludovic Courtès <ludo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 30 Oct 2021 14:21:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 10:21:38 2021
Received: from localhost ([127.0.0.1]:58099 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgpEk-000351-Uk
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 10:21:38 -0400
Received: from eggs.gnu.org ([209.51.188.92]:34006)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1mgpEj-00034m-Cn
 for 51466 <at> debbugs.gnu.org; Sat, 30 Oct 2021 10:21:33 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:54362)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mgpEd-0005pv-JZ; Sat, 30 Oct 2021 10:21:27 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=x1sDf2DFW+7J17UtvkUvRlkDCPGBCHtts97TmSqm9lA=; b=gSlMEwIDuzWGyxpOwlZo
 7W5uLA6NvsKCGXgZ/2VqCRAOvRCKnXtK+J3WsarxPyn3rJgTWub3TaF5dDx/3YuD7Yi/HZUNQH24c
 TBKaUO1it764Dw+s9FI199YcgQ7Gl1ZDIfqXBxij7MiQrklkp3F5R3mJd9vxZk5C7CYoooujH86jB
 xd8molsSstOaaMMaPjI6Lodpk4HEBzEF6d1MN9vsRqskueSeaSueAejV4QQWsUOqCjOhhgWIJOj/e
 Ej0ZVRRoSy9LD/PbES4IFYT7IY+eBPZipzW5FeYB57WWq6pDkaIb+14tEDmn8buPr/DhiRKZXyxU2
 MDcnPAAychH7Sw==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:55484
 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mgpEd-0008Op-6h; Sat, 30 Oct 2021 10:21:27 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Vagrant Cascadian <vagrant@HIDDEN>
Subject: Re: bug#51466: guix shell --check reports missing PKG_CONFIG_PATH
 on Debian bookworm
References: <87r1c5c6gk.fsf@ponder> <87o877y7kd.fsf@HIDDEN>
 <87k0hvggu1.fsf@yucca>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 9 Brumaire an 230 de la =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Sat, 30 Oct 2021 16:21:25 +0200
In-Reply-To: <87k0hvggu1.fsf@yucca> (Vagrant Cascadian's message of "Fri, 29
 Oct 2021 23:35:50 -0700")
Message-ID: <87lf2atwyi.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51466
Cc: 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Howdy!

Vagrant Cascadian <vagrant@HIDDEN> skribis:

> On 2021-10-29, Ludovic Court=C3=A8s wrote:

[...]

>> If you look at =E2=80=98child-shell-environment=E2=80=99 in (guix script=
s environment),
>> it runs this in the child shell:
>>
>>   env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit
>>
>> If the shell prints non-newline-terminated stuff before the output of
>> =E2=80=98env=E2=80=99, the first line of =E2=80=98env=E2=80=99 would be =
swallowed by the parser below.
>>
>> Could you run:
>>
>>   strace -o log -s 500 guix shell --check -D guix
>>
>> to see exactly what =E2=80=98guix shell=E2=80=99 reads?
>
> That showed nothing obvious to me; the log it spits out is about 3MB
> (~320k compressed with zstd) I could attach if it is useful...
>
> I did notice SHELL=3D/bin/bash, and tried an experiment:
>
>   $ SHELL=3D/gnu/store/87kif0bpf0anwbsaw0jvg8fyciw4sz67-bash-5.0.16/bin/b=
ash guix shell --check -D guix
>   guix shell: checking the environment variables visible from shell
>   '/gnu/store/87kif0bpf0anwbsaw0jvg8fyciw4sz67-bash-5.0.16/bin/bash'...
>   guix shell: All is good!  The shell gets correct environment variables.
>
> So, somehow the value of SHELL and/or the user's default shell is
> triggering the issue?

Yes, =E2=80=98--check=E2=80=99 runs $SHELL.

To make sure, could you try with the attached patch to see exactly which
variables =E2=80=98guix shell=E2=80=99 =E2=80=9Csees=E2=80=9D, and whether =
it drops a line it shouldn=E2=80=99t
drop?

TIA,
Ludo=E2=80=99.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index cca0ad991b..7f3d3b9db8 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -452,10 +452,10 @@ (define lines
           ;; but it also truncates values anyway, so don't try to support it.
           (let ((index (string-index line #\=)))
             (if index
-                (vhash-cons (string-take line index)
+                (vhash-cons (pk 'variable line (string-take line index))
                             (string-drop line (+ 1 index))
                             table)
-                table)))
+                (pk 'dropped line table))))
         vlist-null
         lines))
 

--=-=-=--




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 30 Oct 2021 06:36:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 02:36:05 2021
Received: from localhost ([127.0.0.1]:56570 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mghyH-0004N1-MG
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 02:36:05 -0400
Received: from cascadia.aikidev.net ([173.255.214.101]:42152)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vagrant@HIDDEN>) id 1mghyC-0004MR-Vo
 for 51466 <at> debbugs.gnu.org; Sat, 30 Oct 2021 02:36:04 -0400
Received: from localhost (unknown [IPv6:2600:3c01:e000:21:21:21:0:100b])
 (Authenticated sender: vagrant@HIDDEN)
 by cascadia.aikidev.net (Postfix) with ESMTPSA id 0F3CD1AA2C;
 Fri, 29 Oct 2021 23:35:55 -0700 (PDT)
From: Vagrant Cascadian <vagrant@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#51466: guix shell --check reports missing PKG_CONFIG_PATH
 on Debian bookworm
In-Reply-To: <87o877y7kd.fsf@HIDDEN>
References: <87r1c5c6gk.fsf@ponder> <87o877y7kd.fsf@HIDDEN>
Date: Fri, 29 Oct 2021 23:35:50 -0700
Message-ID: <87k0hvggu1.fsf@yucca>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 51466
Cc: 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 2021-10-29, Ludovic Court=C3=A8s wrote:
> Vagrant Cascadian <vagrant@HIDDEN> skribis:
>
>> Most things seem to work fine, but noticed an oddity with guix shell:
>>
>> vagrant@vagranttdgxbookworm:~$ guix shell --pure --check --development g=
uix guix git less
>>
>> guix shell: checking the environment variables visible from shell
>> '/bin/bash'...
>> guix shell: warning: variable 'PKG_CONFIG_PATH' is missing from shell
>
> [...]
>
>> vagrant@vagranttdgxbookworm:~$ guix shell --pure --development guix guix=
 git less
>>
>> vagrant@vagranttdgxbookworm:~$ echo $PKG_CONFIG_PATH
>> /gnu/store/9vk59alg27y0cp1za91nfdjiy718cn1f-profile/lib/pkgconfig
>
> Notice that it doesn=E2=80=99t complain about any of the other environment
> variables (there are 10 of them according to =E2=80=98guix shell -D guix
> --search-paths|wc -l=E2=80=99).
>
> If you look at =E2=80=98child-shell-environment=E2=80=99 in (guix scripts=
 environment),
> it runs this in the child shell:
>
>   env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit
>
> If the shell prints non-newline-terminated stuff before the output of
> =E2=80=98env=E2=80=99, the first line of =E2=80=98env=E2=80=99 would be s=
wallowed by the parser below.
>
> Could you run:
>
>   strace -o log -s 500 guix shell --check -D guix
>
> to see exactly what =E2=80=98guix shell=E2=80=99 reads?

That showed nothing obvious to me; the log it spits out is about 3MB
(~320k compressed with zstd) I could attach if it is useful...

I did notice SHELL=3D/bin/bash, and tried an experiment:

  $ SHELL=3D/gnu/store/87kif0bpf0anwbsaw0jvg8fyciw4sz67-bash-5.0.16/bin/bas=
h guix shell --check -D guix
  guix shell: checking the environment variables visible from shell
  '/gnu/store/87kif0bpf0anwbsaw0jvg8fyciw4sz67-bash-5.0.16/bin/bash'...
  guix shell: All is good!  The shell gets correct environment variables.

So, somehow the value of SHELL and/or the user's default shell is
triggering the issue?


live well,
  vagrant

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQRlgHNhO/zFx+LkXUXcUY/If5cWqgUCYXznxgAKCRDcUY/If5cW
qpfbAP9089bV8OFTOUgGd2qJo+nVRx8mnMlTow4V+p63ONpotwD+Itq3TH9KiVRb
TQ90cqEOIb8M/QVRpyN0I2imW1+yXQ0=
=Dy+s
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at 51466 <at> debbugs.gnu.org:


Received: (at 51466) by debbugs.gnu.org; 29 Oct 2021 19:06:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 29 15:06:38 2021
Received: from localhost ([127.0.0.1]:55927 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgXD3-00081D-O1
	for submit <at> debbugs.gnu.org; Fri, 29 Oct 2021 15:06:37 -0400
Received: from eggs.gnu.org ([209.51.188.92]:54012)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1mgXD1-00080t-M1
 for 51466 <at> debbugs.gnu.org; Fri, 29 Oct 2021 15:06:36 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:50396)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mgXCw-0004SF-4D; Fri, 29 Oct 2021 15:06:30 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=jx3LZTwkn3BdCehjDELtvlqzISY/VHpu03vUcYVB7c8=; b=bbMX5Fo9Whq6RVQE//d8
 Xmd5lra4kygT1JZKaiTBhCS17ju78zLcYaz2RZrCFLXuAPaYuXLvPTVbL9Cu6q/JIaIBaH6XyMG4h
 cRYUjgiI/2AgK/8S5ErhKThMvChqnnOJ6/WmL3CYHbXIHTGrmmVjJoVSzY5j3nAOlGbzKL9+WIimJ
 97kAVZozZslbAm6AgKSEmks4fIR5qykajTJDF2dZLedRq61r+vGbsC5tM0KZmk7X0+HGrhPSiuZ3s
 /mfg/kNoFqn+8I9PigrLXD0x+GxPnaZT9bsW/S1Rbz9gsZNVEx/oEoaQ6CW6KLKaIqLdGIpmnYnFY
 GCVK/XHHnCMbcg==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:54874
 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mgXCv-0000dd-Mq; Fri, 29 Oct 2021 15:06:29 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Vagrant Cascadian <vagrant@HIDDEN>
Subject: Re: bug#51466: guix shell --check reports missing PKG_CONFIG_PATH
 on Debian bookworm
References: <87r1c5c6gk.fsf@ponder>
Date: Fri, 29 Oct 2021 21:06:26 +0200
In-Reply-To: <87r1c5c6gk.fsf@ponder> (Vagrant Cascadian's message of "Thu, 28
 Oct 2021 12:08:59 -0700")
Message-ID: <87o877y7kd.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51466
Cc: 51466 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi!

Vagrant Cascadian <vagrant@HIDDEN> skribis:

> Most things seem to work fine, but noticed an oddity with guix shell:
>
> vagrant@vagranttdgxbookworm:~$ guix shell --pure --check --development gu=
ix guix git less
>
> guix shell: checking the environment variables visible from shell
> '/bin/bash'...
> guix shell: warning: variable 'PKG_CONFIG_PATH' is missing from shell

[...]

> vagrant@vagranttdgxbookworm:~$ guix shell --pure --development guix guix =
git less
>
> vagrant@vagranttdgxbookworm:~$ echo $PKG_CONFIG_PATH
> /gnu/store/9vk59alg27y0cp1za91nfdjiy718cn1f-profile/lib/pkgconfig

Notice that it doesn=E2=80=99t complain about any of the other environment
variables (there are 10 of them according to =E2=80=98guix shell -D guix
--search-paths|wc -l=E2=80=99).

If you look at =E2=80=98child-shell-environment=E2=80=99 in (guix scripts e=
nvironment),
it runs this in the child shell:

  env || /usr/bin/env || set; echo GUIX-CHECK-DONE; read x; exit

If the shell prints non-newline-terminated stuff before the output of
=E2=80=98env=E2=80=99, the first line of =E2=80=98env=E2=80=99 would be swa=
llowed by the parser below.

Could you run:

  strace -o log -s 500 guix shell --check -D guix

to see exactly what =E2=80=98guix shell=E2=80=99 reads?

If there=E2=80=99s nothing obvious, you know the story: we can always add =
=E2=80=98pk=E2=80=99
calls in =E2=80=98child-shell-environment=E2=80=99.  :-)

Thanks,
Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 28 Oct 2021 19:09:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 28 15:09:38 2021
Received: from localhost ([127.0.0.1]:53223 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgAmK-0001QV-MT
	for submit <at> debbugs.gnu.org; Thu, 28 Oct 2021 15:09:38 -0400
Received: from lists.gnu.org ([209.51.188.17]:53102)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vagrant@HIDDEN>) id 1mgAmF-0001QH-3t
 for submit <at> debbugs.gnu.org; Thu, 28 Oct 2021 15:09:30 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:37758)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vagrant@HIDDEN>)
 id 1mgAm9-00059O-2o
 for bug-guix@HIDDEN; Thu, 28 Oct 2021 15:09:26 -0400
Received: from cascadia.aikidev.net ([173.255.214.101]:54840)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <vagrant@HIDDEN>) id 1mgAm6-00019x-Jp
 for bug-guix@HIDDEN; Thu, 28 Oct 2021 15:09:20 -0400
Received: from localhost (unknown [IPv6:2600:3c01:e000:21:21:21:0:100e])
 (Authenticated sender: vagrant@HIDDEN)
 by cascadia.aikidev.net (Postfix) with ESMTPSA id 939091AA2C
 for <bug-guix@HIDDEN>; Thu, 28 Oct 2021 12:09:11 -0700 (PDT)
From: Vagrant Cascadian <vagrant@HIDDEN>
To: bug-guix@HIDDEN
Subject: guix shell --check reports missing PKG_CONFIG_PATH on Debian bookworm
Date: Thu, 28 Oct 2021 12:08:59 -0700
Message-ID: <87r1c5c6gk.fsf@ponder>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
Received-SPF: none client-ip=173.255.214.101; envelope-from=vagrant@HIDDEN;
 helo=cascadia.aikidev.net
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_NONE=0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

This is a recently installed Debian bookworm system, initially using the
package from debian experimental (guix 1.3.0-3, built with guile 3.0),
and "guix pull" up to a recent guix master:

vagrant@vagranttdgxbookworm:~$ guix describe
Generation 7    Oct 28 2021 11:04:25    (current)
  guix 0e6470b
    repository URL: /home/vagrant/src/guix
    branch: master
    commit: 0e6470b47f00470c213fbf20bddc5bcf1e2f8e2a


Most things seem to work fine, but noticed an oddity with guix shell:

vagrant@vagranttdgxbookworm:~$ guix shell --pure --check --development guix guix git less

guix shell: checking the environment variables visible from shell
'/bin/bash'...
guix shell: warning: variable 'PKG_CONFIG_PATH' is missing from shell
environment
hint: One or more environment variables have a different value in the
shell than the one we set.  This means that you may find yourself
running code in an environment different from the one you asked Guix to
prepare.

This usually indicates that your shell startup files are unexpectedly
modifying those environment variables.  For example, if you
are using Bash, make sure that environment variables are set or modified
in `~/.bash_profile' and _not_ in `~/.bashrc'.  For more
information on Bash startup files, run:

     info "(bash) Bash Startup Files"

Alternatively, you can avoid the problem by passing the `--container' or
`-C' option.  That will give you a fully isolated
environment running in a "container", immune to the issue described
above.

vagrant@vagranttdgxbookworm:~$ guix shell --pure --development guix guix git less

vagrant@vagranttdgxbookworm:~$ echo $PKG_CONFIG_PATH
/gnu/store/9vk59alg27y0cp1za91nfdjiy718cn1f-profile/lib/pkgconfig


So, --check seems to think the environment variable is missing but
running without --check the variable is defined...

I don't see anything obviously relevent in /etc/profile/ or
/etc/profile.d/guix.sh or /etc/profile.d/bash-completions.sh or
~/.profile or ~/.bashrc ... just used the defaults that shipped in
Debian.


live well,
  vagrant

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQRlgHNhO/zFx+LkXUXcUY/If5cWqgUCYXr1UgAKCRDcUY/If5cW
quNBAP9rKrI7XSjsfxSFRJhJDY62J8PGtJRe7KJrqg7SaxDSQQEA6jpZL4/0xHFu
lrPBTdWmpRSK0MM/wY/oH34Z8On0JA4=
=/3/d
-----END PGP SIGNATURE-----
--=-=-=--




Acknowledgement sent to Vagrant Cascadian <vagrant@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guix@HIDDEN. Full text available.
Report forwarded to bug-guix@HIDDEN:
bug#51466; Package guix. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 20 May 2022 21:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.