GNU bug report logs - #57031
[PATCH] scripts: Show a hint the first time some commands are run as root.

Previous Next

Package: guix-patches;

Reported by: "(" <paren <at> disroot.org>

Date: Sun, 7 Aug 2022 11:15:02 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: "(" <paren <at> disroot.org>
Cc: 57031 <at> 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
Hello,

"(" <paren <at> 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’.




This bug report was last modified 2 years and 236 days ago.

Previous Next


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