From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8KLjGlCabmEWsAAAgWs5BA (envelope-from ) for ; Tue, 19 Oct 2021 12:13:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WNiVFlCabmHXEAAAB5/wlQ (envelope-from ) for ; Tue, 19 Oct 2021 10:13:36 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D8CBA12924 for ; Tue, 19 Oct 2021 12:13:35 +0200 (CEST) Received: from localhost ([::1]:47006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcm7h-0002Sd-Bc for larch@yhetil.org; Tue, 19 Oct 2021 06:13:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mclzS-0007u5-Qw for guix-patches@gnu.org; Tue, 19 Oct 2021 06:05:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mclzS-00008i-HY for guix-patches@gnu.org; Tue, 19 Oct 2021 06:05:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mclzS-00073n-8n for guix-patches@gnu.org; Tue, 19 Oct 2021 06:05:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51285] [PATCH 0/3] Add 'guix shell --check' Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 19 Oct 2021 10:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51285 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51285@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163463784727068 (code B ref -1); Tue, 19 Oct 2021 10:05:02 +0000 Received: (at submit) by debbugs.gnu.org; 19 Oct 2021 10:04:07 +0000 Received: from localhost ([127.0.0.1]:49435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mclyY-00072W-PM for submit@debbugs.gnu.org; Tue, 19 Oct 2021 06:04:07 -0400 Received: from lists.gnu.org ([209.51.188.17]:59126) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mclyT-000724-AF for submit@debbugs.gnu.org; Tue, 19 Oct 2021 06:04:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mclyS-00069B-Q3 for guix-patches@gnu.org; Tue, 19 Oct 2021 06:04:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47766) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mclyS-0007iX-Hg; Tue, 19 Oct 2021 06:04:00 -0400 Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:54291 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mclyS-0003y1-89; Tue, 19 Oct 2021 06:04:00 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 19 Oct 2021 12:03:51 +0200 Message-Id: <20211019100351.9726-1-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1634638415; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nxQsBZK6wQqF87jBoC3Tb3Xe9rpFU1CLBqIVCFM025E=; b=N1wQJg7WG2K2voB/8QoKmli9TXVeK8Vu3RA1yuN5zoYJSYjuU0tu7mQopg7cXOk+wc28P3 kSKiRpj28qXesDr/xeb/o/XEJWH6VYli5g40rdReN+1TCLLa80bDZvfw7VwlXpuzfcFGRj td+7aX0+DUPQ7KfWOlA5k4PRJlMOFhb4wqskE6kRgv93fV6vwRlpdeELIvxMDa1a13o1aH o9pV6R4XKL5c7/qZE+gbbKm3C9Iq1fniIcvzOuBbRf1E7hXHlK6iPRy3EK6p/8yGKc3ROJ 7KfkGQcFRqix1KukvZP6tsvly0ChEAF6sxN1Jlm5ebpJIslQjQk0A670r/Uulg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1634638415; a=rsa-sha256; cv=none; b=B5SvNpCpc6nJ6+M0PILyHkRLmhcpBoW5PYZoOT0bBpdapukiFPqiixWtRefGlwPOOrEv9F n1KYntE+lRX5Iy3VmFcuAIfMEroYBc+SRTLwlTAgV5+/bsrH4uJ0qs3Z23vMEj32JD8jr5 F1Q+9ibwEx6WJw+w2vuwDnOvkhuinzoLeWIPCrzapckfnjzo3DvfyZ/LJ/P/hkGGP5IiIz PbAD7ePSiB1xVin+54q6a5bZO2j0OBGWKPtocXGl5QfeT0w/mtih8RFu3dTgKtCoQeId12 +ulaKAsYU5H2ic5k4aa0aiOrR0CogdGsxzPgi51eThgdSRh79RwT+aWYh4rHIw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -2.73 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: D8CBA12924 X-Spam-Score: -2.73 X-Migadu-Scanner: scn1.migadu.com X-TUID: OQvnJXg2/RuX Hello Guix! You may be familiar with the crucial footnote about shell startup files: https://guix.gnu.org/manual/en/html_node/Invoking-guix-environment.html#FOOT11 In short, if your shell startup file mess up with environment variables, ‘--pure’ won’t deliver its promise. That’s a common source of annoyance. This patch set adds a ‘--check’ option to ‘guix shell’ (and ‘guix environment’ as well, mostly out of simplicity). Here’s an example: --8<---------------cut here---------------start------------->8--- $ tail -2 ~/.bashrc echo "hi from bashrc!" export PATH=muahahaaa:$PATH $ ./pre-inst-env guix shell --check coreutils guix shell: checking the environment variables visible from shell '/gnu/store/87kif0bpf0anwbsaw0jvg8fyciw4sz67-bash-5.0.16/bin/bash'... guix shell: warning: variable 'PATH' is clobbered: 'muahahaaa:/gnu/store/cq8sfmm6in0r4nfx0zxjvx1fg5ky6a7r-profile/bin' 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. --8<---------------cut here---------------end--------------->8--- Once I’ve cleaned up ~/.bashrc, I can check again and proceed: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix shell --check coreutils 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. [env]$ uname -o GNU/Linux --8<---------------cut here---------------end--------------->8--- This works by launching an interactive shell in a pseudo-terminal, and running “env” or “set” in that shell to retrieve the list of environment variables once it has sourced its startup files. It works well with Bash, Zsh, and presumably any POSIX shell. It kinda works with fish, but that’s not entirely clear. To allow users to learn about this option, the last patch has ‘guix shell’ print a suggest to run ‘--check’ if (1) the hint has never been printed, (2) the user is doing an interactive session, and (3) the user did not pass ‘--container’ or ‘--search-paths’. Thoughts? Ludo’. Ludovic Courtès (3): syscalls: Add 'openpty' and 'login-tty'. environment: Add '--check'. shell: Suggest running '--check' once for interactive use. doc/guix.texi | 39 ++++++--- guix/build/syscalls.scm | 39 +++++++++ guix/scripts/environment.scm | 162 ++++++++++++++++++++++++++++++++++- guix/scripts/shell.scm | 41 ++++++++- tests/syscalls.scm | 35 ++++++++ 5 files changed, 303 insertions(+), 13 deletions(-) base-commit: 467d599bd972f16a958a394827bc925bc497c19a -- 2.33.0