From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uLnoE1JmFmMnogAAbAwnHQ (envelope-from ) for ; Mon, 05 Sep 2022 23:12:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yAINFFJmFmOsEAAA9RJhRA (envelope-from ) for ; Mon, 05 Sep 2022 23:12:50 +0200 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 294333FA5B for ; Mon, 5 Sep 2022 23:12:50 +0200 (CEST) Received: from localhost ([::1]:60528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVJOj-0001ya-Ai for larch@yhetil.org; Mon, 05 Sep 2022 17:12:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVJNz-0000oe-CF for guix-patches@gnu.org; Mon, 05 Sep 2022 17:12:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60359) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVJNy-00030p-NZ for guix-patches@gnu.org; Mon, 05 Sep 2022 17:12:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oVJNy-0002v8-Bu for guix-patches@gnu.org; Mon, 05 Sep 2022 17:12:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57031] [PATCH] scripts: Show a hint the first time some commands are run as root. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 05 Sep 2022 21:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57031 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: 57031@debbugs.gnu.org Received: via spool by 57031-submit@debbugs.gnu.org id=B57031.166241228111180 (code B ref 57031); Mon, 05 Sep 2022 21:12:02 +0000 Received: (at 57031) by debbugs.gnu.org; 5 Sep 2022 21:11:21 +0000 Received: from localhost ([127.0.0.1]:49058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oVJNJ-0002uF-68 for submit@debbugs.gnu.org; Mon, 05 Sep 2022 17:11:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oVJNH-0002u2-GD for 57031@debbugs.gnu.org; Mon, 05 Sep 2022 17:11:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVJNC-0002yl-3g; Mon, 05 Sep 2022 17:11:14 -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=ZfuHBFKHKKcDt0YvsoliiCRGoUaD2rmrRcuTh6xMJBY=; b=ZbsPdolsDjyMA1OL3yTy pp7N+CyWa7J5Izaeb06rD7G2LurEl1G0jVkVDbgGiHfew4DEMVgdBWo7IuSeaD3T0hT31rcoov3QO EGxE9cons6CnGVvgb2HnZXK5v2CplScGkJ9IXTkv5LXPJsL0Jgh3ZwTDpzgWBjHsGivpO+G3QYlwk drU4zV3s3P6vpD9gsMyFSikbs2jgpi+V7k5wAAcRP3/QjH9U14XmgOS1NTKecreSzq5Tpb0tEx8ME UKE2xVlMl0rCctg5BPRlZD27f+E4EBOkddFgInm/bYS9QaqQGFUAUV3xKS5RsjKgxbvc1TtyBsJef THe3wZTWrE0acA==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33234 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVJNB-0003qE-NW; Mon, 05 Sep 2022 17:11:13 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20220807111421.14771-1-paren@disroot.org> <20220807111929.15617-1-paren@disroot.org> Date: Mon, 05 Sep 2022 23:11:11 +0200 In-Reply-To: <20220807111929.15617-1-paren@disroot.org> (paren@disroot.org's message of "Sun, 7 Aug 2022 12:19:29 +0100") Message-ID: <87tu5l1q8g.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1662412370; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ZfuHBFKHKKcDt0YvsoliiCRGoUaD2rmrRcuTh6xMJBY=; b=J7aO11Pt9+0JPdU48oCtAKwrvQ65SRQMRJQqpNVyHSk+PiIqHtTEFr3Evxji2H0KCMmNXs BDh56zemhjvPq7EuOjW+nbxtS3EDhXkRogdUV9cmfX2DHehTeDLmqnBBojgwTm2LmhrS9V tdBv8U4tQ8aOEKWIeOwVe/CLIFrY4X5jb3Gf2006iMkH918RAk4T3eZCZCE2A7879YVJ4Z OizAIF29T9K33Ox/4XlIN0I7A6r2sBIba/M3hPVOiOZwMTX93dLGGfTqi4pTgUZ7Wrflk6 2yyrJsJM5hYjSH0ukxmdFdyIr18WJm3MDGxGL/nRWaI6fiXUMmNfXIp8fMzwTw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662412370; a=rsa-sha256; cv=none; b=TVwC99AlM+7GdK9wu5v84ymWaoDGJLKdCwAlhbo26g90O/+xGM487vGxMZxXq5ZscWEIye G3ANGn3ks5Z+U4EZ2SLgcaPyri47aMaSX5ygNJyTroTOHKajqJQL3DeNgMC9qPJg1NVFTl tcv9wfsN8j2hcDdi5s4TA+yWMQOA8dZG7m7w/5bwwUksg7SWt8k+9Cq/llJKYv/A3hF3hd liqabCWLhQC2F5nNNpSlZYsAcSs83wEZiHzYlaB1IhUcS5WRmwErdDp4ruyshKUA4785+1 oZEOH6JCSZ7yf/v1AXuYIbfV3RH021OA1aheyt2nbRiYVqZQ9NuqWNV6CxNHSw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=ZbsPdols; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.57 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=ZbsPdols; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 294333FA5B X-Spam-Score: -3.57 X-Migadu-Scanner: scn0.migadu.com X-TUID: KV6INMf5fHbY Hello, "(" skribis: > * guix/scripts/shell.scm (hint-given?, hint-directory, hint-file, > record-hint): Move these... > * guix/ui.scm: ...here. Export them. > * guix/scripts/package.scm (guix-package*): Add `#:root-hint?` keyword > argument. Display a hint if Guix is being run as root and `root-hint?` > is #t. > * guix/scripts/install.scm (guix-install): Use `#:root-hint? #t` here... > * guix/scripts/remove.scm (guix-remove): ...here... > * guix/scripts/upgrade.scm (guix-upgrade): ...and here. > * guix/scripts/pull.scm (guix-pull): (guix-pull): Display a hint if > Guix is being run as root. > > A pretty common beginner mistake, it seems, is assuming that since > every other package manager you've used requires root for installing, > removing, and upgrading packages, Guix must too. > > This commit tries to make it harder to make such an assumption, by > making commands such as `pull`, `package`, and `upgrade` display > a hint the first time they are run as root. I like this change! One nitpick: Could you make moving the hint code from shell.scm to ui.scm a separate commit? [...] > + (display-hint (G_ "`guix pull' is user-specific, not system-wid= e; > +running it as root will only affect the `root' user."))) Please use Texinfo markup in hints: @command{guix pull}, etc. (Likewise for the second hint.) > +(define* (guix-package* opts #:key (root-hint? #f)) > "Run the 'guix package' command on OPTS, an alist resulting for comman= d-line > -option processing with 'parse-command-line'." > +option processing with 'parse-command-line'. If ROOT-HINT? is #T, a hin= t is > +shown on the first usage of this procedure that informs users about Guix= 's > +support for per-user package management." > (with-error-handling > + (when (and root-hint? > + (not (hint-given? 'package-root-hint)) > + (=3D (getuid) 0)) Unless I=E2=80=99m mistaken, =E2=80=98root-hint?=E2=80=99 is always true; s= hould we just remove it? BTW, when running =E2=80=98sudo guix install=E2=80=99, the hint is going to ~root/.cache/guix, right? Thanks, Ludo=E2=80=99.