Bah!  I goofed on the attachment.  Sorry for the trouble.  Here it is
again.

>From e88baf0363607d4e072f5a29a2cd01ededfa00d2 Mon Sep 17 00:00:00 2001
From: Timothy Sample <[email protected]>
Date: Sat, 15 Dec 2018 12:57:52 -0500
Subject: [PATCH] environment: Print command name on execlp error.

Fixes <https://bugs.gnu.org/33755>.

* guix/scripts/environment.scm: When execlp raises ENOENT, print a
clear error message and exit with status 127 (like a shell would).
---
 guix/scripts/environment.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 5965e3426..27483acb2 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -389,7 +389,15 @@ variables are cleared before setting the new ones."
   (create-environment profile manifest #:pure? pure?)
   (match command
     ((program . args)
-     (apply execlp program program args))))
+     (catch 'system-error
+       (lambda ()
+         (apply execlp program program args))
+       (lambda args
+         (if (= ENOENT (system-error-errno args))
+             (begin
+               (report-error (G_ "~a: command not found~%") program)
+               (exit 127))
+             (apply throw args)))))))
 
 (define* (launch-environment/fork command profile manifest #:key pure?)
   "Run COMMAND in a new process with an environment containing PROFILE, with
-- 
2.20.0

Timothy Sample <[email protected]> writes:

> Hi,
>
> Julien Lepiller <[email protected]> writes:
>
>> Hi, this is because we have a -- option. "guix environment guix --
>> ad-hoc libgit2" means you want to run "ad-hoc libgit2" in a guix
>> environment. The error message tells you that it can't find an ad-hoc
>> executable in that environment. There is no "ad-hoc" package involved
>> here…
>
> This is true, but I would argue that the error message is not quite as
> clear as you say.  Specifically, it does not mention “ad-hoc” at all.
> I’ve attached a patch that so that the command
>
>     $ guix environment guix -- ad-hoc
>
> prints
>
>     guix environment: error: ad-hoc: command not found
>
> and exits with status 127.  (In imitation of “bash -c 'ad-hoc'”.)
>
> Thoughts?
>
>> Le 15 décembre 2018 08:09:37 GMT+01:00, [email protected] a écrit :
>>>Hi
>>>
>>>Is this a bug?
>>>
>>>sdb@antelope ~/src/guix$ guix environment guix -- ad-hoc libgit2
>>>texinfo
>>>guix environment: error: execlp: No such file or directory
>>>
>>>I meant to type: 
>>>sdb@antelope ~/src/guix$ guix environment guix --ad-hoc libgit2 texinfo
>>>
>>>I would have liked an error saying "error: package ad-hoc not found -
>>>cannot add it to the environment"
>
>
> -- Tim

Reply via email to