all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: "(" <paren@disroot.org>
Cc: 57031@debbugs.gnu.org
Subject: [bug#57031] [PATCH] scripts: Show a hint the first time some commands are run as root.
Date: Mon, 05 Sep 2022 23:11:11 +0200	[thread overview]
Message-ID: <87tu5l1q8g.fsf_-_@gnu.org> (raw)
In-Reply-To: <20220807111929.15617-1-paren@disroot.org> (paren@disroot.org's message of "Sun, 7 Aug 2022 12:19:29 +0100")

Hello,

"(" <paren@disroot.org> 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-wide;
> +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 command-line
> -option processing with 'parse-command-line'."
> +option processing with 'parse-command-line'.  If ROOT-HINT? is #T, a hint 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))
> +               (= (getuid) 0))

Unless I’m mistaken, ‘root-hint?’ is always true; should we just remove
it?

BTW, when running ‘sudo guix install’, the hint is going to
~root/.cache/guix, right?

Thanks,
Ludo’.




  parent reply	other threads:[~2022-09-05 21:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-07 11:14 [bug#57031] [PATCH] scripts: Show a hint the first time some commands are run as root ( via Guix-patches via
2022-08-07 11:19 ` [bug#57031] [PATCH v2] " ( via Guix-patches via
2022-08-07 11:22   ` ( via Guix-patches via
2022-09-05 21:11   ` Ludovic Courtès [this message]
2022-09-11 13:05     ` [bug#57031] [PATCH] " ( via Guix-patches via
2022-09-11 19:59 ` [bug#57031] [PATCH v2 1/2] ui: Make one-time hint API public ( via Guix-patches via
2022-09-11 19:59   ` [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root ( via Guix-patches via
2022-10-26 18:14     ` zimoun
2022-10-27  5:52       ` ( via Guix-patches via
2022-10-27  8:23         ` zimoun
2022-10-28 14:33           ` ( via Guix-patches via
2022-10-27 19:42 ` [bug#57031] [PATCH v3 1/2] ui: Make one-time hint API public ( via Guix-patches via
2022-10-27 19:42   ` [bug#57031] [PATCH v3 2/2] scripts: Warn the first time pull or package is run as root ( via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tu5l1q8g.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=57031@debbugs.gnu.org \
    --cc=paren@disroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.