[PATCH] scripts: home/system: Don’t throw an error if no generations exist.

  • Done
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Maxime Devos
  • Xinglu Chen
Owner
unassigned
Submitted by
Xinglu Chen
Severity
normal
X
X
Xinglu Chen wrote on 2 Oct 2021 23:05
[PATCH] scripts: home/system: Don’t throw an error if no generations exist.
(address . guix-patches@gnu.org)
8c1286034c3a48353d13515f04883dbede289e0c.1633208618.git.public@yoctocell.xyz
Previously, When running ‘guix home describe’ or ‘guix system describe’ prior
to having any generations, a backtrace would produced. Since not having any
existing generations is not an error, a warning would be enough.

$ guix system describe
guix system: warning: no system generation, nothing to describe

* guix/scripts/home.scm (process-command): Produce a warning instead of an
error if no generations exist.
* guix/scripts/system.scm (process-command): Likewise.

Reported-by: Maxime Devos <maximedevos@telenet.be>
---
guix/scripts/home.scm | 2 +-
guix/scripts/system.scm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

Toggle diff (30 lines)
diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm
index 75df6d707d..70860564eb 100644
--- a/guix/scripts/home.scm
+++ b/guix/scripts/home.scm
@@ -260,7 +260,7 @@ (define-syntax-rule (with-store* store exp ...)
((describe)
(match (generation-number %guix-home)
(0
- (error (G_ "no home environment generation, nothing to describe~%")))
+ (warning (G_ "no home environment generation, nothing to describe~%")))
(generation
(display-home-environment-generation generation))))
((list-generations)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 65eb98e4b2..d77d3ea289 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -1307,7 +1307,7 @@ (define-syntax-rule (with-store* store exp ...)
((describe)
(match (generation-number %system-profile)
(0
- (error (G_ "no system generation, nothing to describe~%")))
+ (warning (G_ "no system generation, nothing to describe~%")))
(generation
(display-system-generation generation))))
((search)

base-commit: f1a3c11407b52004e523ec5de20d326c5661681f
--
2.33.0
M
M
Maxime Devos wrote on 3 Oct 2021 10:53
Re: [bug#50982] [PATCH] scripts: home/system: Don’t throw an error if no generations exist.
dcec2546aea2940cae52274422a643ef5a0189da.camel@telenet.be
Xinglu Chen schreef op za 02-10-2021 om 23:05 [+0200]:
Toggle quote (7 lines)
> Previously, When running ‘guix home describe’ or ‘guix system describe’ prior
> to having any generations, a backtrace would produced. Since not having any
> existing generations is not an error, a warning would be enough.
>
> $ guix system describe
> guix system: warning: no system generation, nothing to describe

Printing a warning instead of an error to avoid a backrace isn't necessary.
E.g., "guix show i-do-not-exists" prints an error
‘guix show: error: i-do-not-exist: package not found’.

I suggest using (leave (G_ "bla bla")) instead of (error (G_ "bla bla"))
for these kind of errors, it appears to work '%find-package' in (gnu packages).

I don't know if the output of "guix system describe" and "guix home describe"
should be an error or warning here ...

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVlvixccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7iL+AQD+DVHtvsy0TySCdnPSg09nWTyo
OZbErU1Ts9wXO08JrAEA1x1AiNGcy8Tfonp9SAWKS1uXIUd/Fr+SY65oAyUEigc=
=WkOa
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 19 Oct 2021 15:59
Re: bug#50982: [PATCH] scripts: home/system: Don ’t throw an error if no generations exist.
(name . Maxime Devos)(address . maximedevos@telenet.be)
87o87l86ab.fsf_-_@gnu.org
Hi Xinglu,

Did you have a chance to look into this?

TIA!

Ludo’.

Maxime Devos <maximedevos@telenet.be> skribis:

Toggle quote (20 lines)
> Xinglu Chen schreef op za 02-10-2021 om 23:05 [+0200]:
>> Previously, When running ‘guix home describe’ or ‘guix system describe’ prior
>> to having any generations, a backtrace would produced. Since not having any
>> existing generations is not an error, a warning would be enough.
>>
>> $ guix system describe
>> guix system: warning: no system generation, nothing to describe
>
> Printing a warning instead of an error to avoid a backrace isn't necessary.
> E.g., "guix show i-do-not-exists" prints an error
> ‘guix show: error: i-do-not-exist: package not found’.
>
> I suggest using (leave (G_ "bla bla")) instead of (error (G_ "bla bla"))
> for these kind of errors, it appears to work '%find-package' in (gnu packages).
>
> I don't know if the output of "guix system describe" and "guix home describe"
> should be an error or warning here ...
>
> Greetings,
> Maxime.
X
X
Xinglu Chen wrote on 30 Oct 2021 13:18
Re: [bug#50982] [PATCH] scripts: home/system: Don ’t throw an error if no generations exist.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87ee827oc0.fsf@disroot.org
Hi,

On Sun, Oct 03 2021, Maxime Devos wrote:

Toggle quote (18 lines)
> Xinglu Chen schreef op za 02-10-2021 om 23:05 [+0200]:
>> Previously, When running ‘guix home describe’ or ‘guix system describe’ prior
>> to having any generations, a backtrace would produced. Since not having any
>> existing generations is not an error, a warning would be enough.
>>
>> $ guix system describe
>> guix system: warning: no system generation, nothing to describe
>
> Printing a warning instead of an error to avoid a backrace isn't necessary.
> E.g., "guix show i-do-not-exists" prints an error
> ‘guix show: error: i-do-not-exist: package not found’.
>
> I suggest using (leave (G_ "bla bla")) instead of (error (G_ "bla bla"))
> for these kind of errors, it appears to work '%find-package' in (gnu packages).
>
> I don't know if the output of "guix system describe" and "guix home describe"
> should be an error or warning here ...

Hmm, since I don’t think that not having any generations is an error, I
would say it makes more sense to use ‘warning’ instead of ‘leave’.
‘leave’ would signal that something isn’t correct, which makes sense if
one runs ‘guix show doesnt-exist’, but not having any generations
doesn’t really mean that something is wrong.

WDYT?
-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmF9Kg8VHHB1YmxpY0B5
b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5W6cP/219MvUYkwuoH4+/7yCUZqYeoHQx
at9EDmf6Qynah5/kz0xPlhN81Dpmd0RzHCXp9o6wqIaReEaBvLTLc8OdN9iz3V2y
D3BBOIEmCoe6XfSP0cwHQ1Of5hlrbIp1pOc+jLk8gqrXJRswaB07UfRiqD45u+eV
1P+JxkAnFCC2mXvV0YWu1xPGp2XOe8DzJgj7+FGJQCTPbn2/nBvJIBWCphSNNV5N
XaGTNW5CfT4IwbFbt34pa62xkuW9uLz9Rws78tDBHQ2CfmOjAfowvCGlx0eO1XZ/
BKTxUJYthTYfkRxUeY7UH7Oc+RWcBRt1+EV/9JPZY1UmBiYiMMhnBwE53SdhOGhg
ElOpwXxWmphRg+m3vsnourDL2Qpxg60EjhjiRL73nzQtZkPlr0YPSZQ997WRAAAn
NOLEOCDyC2qfAsl90ORVNtoq9Z8JxnyzYvVsWbaE8D0ZeJReK1IcHsL2h/z18TD7
y5F2wcH2t5uiBeJY2mszlqlirjgfgpvR9PgWC96bNqQbwcrtLyIYKW7OwekByK4A
/TPyK73pr8NGMoU1Z1h+CKAjB2xgq8PUuwGSjR7ME23plv5n5QTkoIOHVTDCjveU
O0tw6DkIemyrx7htBuLyiMRmwAbOgKLMzGp3fk4Nj36VHLmmwr7PmHt99pvL2iuL
8a18YcF1l/mXGWg2
=qMIu
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 30 Oct 2021 16:24
(name . Xinglu Chen)(address . public@yoctocell.xyz)
87h7cytwsy.fsf@gnu.org
Hi,

Xinglu Chen <public@yoctocell.xyz> skribis:

Toggle quote (26 lines)
> On Sun, Oct 03 2021, Maxime Devos wrote:
>
>> Xinglu Chen schreef op za 02-10-2021 om 23:05 [+0200]:
>>> Previously, When running ‘guix home describe’ or ‘guix system describe’ prior
>>> to having any generations, a backtrace would produced. Since not having any
>>> existing generations is not an error, a warning would be enough.
>>>
>>> $ guix system describe
>>> guix system: warning: no system generation, nothing to describe
>>
>> Printing a warning instead of an error to avoid a backrace isn't necessary.
>> E.g., "guix show i-do-not-exists" prints an error
>> ‘guix show: error: i-do-not-exist: package not found’.
>>
>> I suggest using (leave (G_ "bla bla")) instead of (error (G_ "bla bla"))
>> for these kind of errors, it appears to work '%find-package' in (gnu packages).
>>
>> I don't know if the output of "guix system describe" and "guix home describe"
>> should be an error or warning here ...
>
> Hmm, since I don’t think that not having any generations is an error, I
> would say it makes more sense to use ‘warning’ instead of ‘leave’.
> ‘leave’ would signal that something isn’t correct, which makes sense if
> one runs ‘guix show doesnt-exist’, but not having any generations
> doesn’t really mean that something is wrong.

Yeah, I guess ‘warning’ is fine.

Maxime’s point is that we should always use procedures from (guix
diagnostics) for error/warning/info reports.

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 6 Jan 2022 11:28
Re: bug#50982: [PATCH] scripts: home/system: Don ’t throw an error if no generations exist.
(name . Maxime Devos)(address . maximedevos@telenet.be)
877dbdf9a1.fsf_-_@gnu.org
Maxime Devos <maximedevos@telenet.be> skribis:

Toggle quote (15 lines)
> Xinglu Chen schreef op za 02-10-2021 om 23:05 [+0200]:
>> Previously, When running ‘guix home describe’ or ‘guix system describe’ prior
>> to having any generations, a backtrace would produced. Since not having any
>> existing generations is not an error, a warning would be enough.
>>
>> $ guix system describe
>> guix system: warning: no system generation, nothing to describe
>
> Printing a warning instead of an error to avoid a backrace isn't necessary.
> E.g., "guix show i-do-not-exists" prints an error
> ‘guix show: error: i-do-not-exist: package not found’.
>
> I suggest using (leave (G_ "bla bla")) instead of (error (G_ "bla bla"))
> for these kind of errors, it appears to work '%find-package' in (gnu packages).

I’ve done that now, thanks!

Ludo’.
Closed
?