all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#33755: error: execlp: No such file or directory from guix environment
@ 2018-12-15  7:09 swedebugia
  2018-12-15  9:40 ` Julien Lepiller
  0 siblings, 1 reply; 9+ messages in thread
From: swedebugia @ 2018-12-15  7:09 UTC (permalink / raw)
  To: 33755

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"

-- 
Cheers 
Swedebugia

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#33755: error: execlp: No such file or directory from guix environment
  2018-12-15  7:09 bug#33755: error: execlp: No such file or directory from guix environment swedebugia
@ 2018-12-15  9:40 ` Julien Lepiller
  2018-12-15 18:18   ` Timothy Sample
  0 siblings, 1 reply; 9+ messages in thread
From: Julien Lepiller @ 2018-12-15  9:40 UTC (permalink / raw)
  To: swedebugia, 33755

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…

Le 15 décembre 2018 08:09:37 GMT+01:00, swedebugia@riseup.net 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"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#33755: error: execlp: No such file or directory from guix environment
  2018-12-15  9:40 ` Julien Lepiller
@ 2018-12-15 18:18   ` Timothy Sample
  2018-12-15 18:35     ` Timothy Sample
  0 siblings, 1 reply; 9+ messages in thread
From: Timothy Sample @ 2018-12-15 18:18 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: swedebugia, 33755

[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]

Hi,

Julien Lepiller <julien@lepiller.eu> 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, swedebugia@riseup.net 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


[-- Attachment #2: /home/samplet/code/3rdparty/guix/0001-environment-Print-command-name-on-execlp-error.patch --]
[-- Type: message/external-body, Size: 102 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#33755: error: execlp: No such file or directory from guix environment
  2018-12-15 18:18   ` Timothy Sample
@ 2018-12-15 18:35     ` Timothy Sample
  2018-12-15 19:38       ` Danny Milosavljevic
  0 siblings, 1 reply; 9+ messages in thread
From: Timothy Sample @ 2018-12-15 18:35 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: swedebugia, 33755

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-environment-Print-command-name-on-execlp-error.patch --]
[-- Type: text/x-patch, Size: 1366 bytes --]

From e88baf0363607d4e072f5a29a2cd01ededfa00d2 Mon Sep 17 00:00:00 2001
From: Timothy Sample <samplet@ngyro.com>
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


[-- Attachment #3: Type: text/plain, Size: 1322 bytes --]


Timothy Sample <samplet@ngyro.com> writes:

> Hi,
>
> Julien Lepiller <julien@lepiller.eu> 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, swedebugia@riseup.net 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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#33755: error: execlp: No such file or directory from guix environment
  2018-12-15 18:35     ` Timothy Sample
@ 2018-12-15 19:38       ` Danny Milosavljevic
  2018-12-16  4:26         ` Timothy Sample
  0 siblings, 1 reply; 9+ messages in thread
From: Danny Milosavljevic @ 2018-12-15 19:38 UTC (permalink / raw)
  To: Timothy Sample; +Cc: swedebugia, 33755

[-- Attachment #1: Type: text/plain, Size: 191 bytes --]

Hi Tim,

I like it in princple, but why special-case ENOENT?  I think it would be better to just always print the program name (and maybe program args, too!) and the system error message.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#33755: error: execlp: No such file or directory from guix environment
  2018-12-15 19:38       ` Danny Milosavljevic
@ 2018-12-16  4:26         ` Timothy Sample
  2018-12-16 16:05           ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Timothy Sample @ 2018-12-16  4:26 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: swedebugia, 33755

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi Tim,
>
> I like it in princple, but why special-case ENOENT?  I think it would
> be better to just always print the program name (and maybe program
> args, too!) and the system error message.

You are right.  I got fixated on the fact that it was failing the $PATH
search, and forgot about the more general cases.  I think printing the
program name and the system error message is the right choice.
According to the manual for “execve”, the arguments only cause an error
if they exceed ARG_MAX, in which case we probably don’t want to print
them anyway.

Here’s an updated patch.  I also got rid of the 127 status code, since
doesn’t make sense for the more general cases.

Thanks for the help!


-- Tim


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-environment-Print-command-name-on-execlp-error.patch --]
[-- Type: text/x-patch, Size: 1256 bytes --]

From aedc745a3f9765ae00dc61a59fa53d22a458551b Mon Sep 17 00:00:00 2001
From: Timothy Sample <samplet@ngyro.com>
Date: Sat, 15 Dec 2018 23:17:46 -0500
Subject: [PATCH] environment: Print command name on execlp error.

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

* guix/scripts/environment.scm (launch-environment): When execlp fails,
include the command name in the error message.
---
 guix/scripts/environment.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 5965e3426..64035a740 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -389,7 +389,12 @@ 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
+         (let ((errno (system-error-errno args)))
+           (leave (G_ "~a: ~a~%") program (strerror errno))))))))
 
 (define* (launch-environment/fork command profile manifest #:key pure?)
   "Run COMMAND in a new process with an environment containing PROFILE, with
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#33755: error: execlp: No such file or directory from guix environment
  2018-12-16  4:26         ` Timothy Sample
@ 2018-12-16 16:05           ` Ludovic Courtès
  2018-12-17  4:41             ` Timothy Sample
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2018-12-16 16:05 UTC (permalink / raw)
  To: Timothy Sample; +Cc: swedebugia, 33755

Hello comrades!

Timothy Sample <samplet@ngyro.com> skribis:

> Danny Milosavljevic <dannym@scratchpost.org> writes:
>
>> Hi Tim,
>>
>> I like it in princple, but why special-case ENOENT?  I think it would
>> be better to just always print the program name (and maybe program
>> args, too!) and the system error message.
>
> You are right.
[...]

> From aedc745a3f9765ae00dc61a59fa53d22a458551b Mon Sep 17 00:00:00 2001
> From: Timothy Sample <samplet@ngyro.com>
> Date: Sat, 15 Dec 2018 23:17:46 -0500
> Subject: [PATCH] environment: Print command name on execlp error.
>
> Fixes <https://bugs.gnu.org/33755>.
>
> * guix/scripts/environment.scm (launch-environment): When execlp fails,
> include the command name in the error message.

Another option would be to do:

  (set! execl
    (error-reporting-wrapper …))

in (guix ui), as done for a few other procedures that have the same
issue.

WDYT?

Ludo’.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#33755: error: execlp: No such file or directory from guix environment
  2018-12-16 16:05           ` Ludovic Courtès
@ 2018-12-17  4:41             ` Timothy Sample
  2018-12-18  9:05               ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Timothy Sample @ 2018-12-17  4:41 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: swedebugia, 33755

[-- Attachment #1: Type: text/plain, Size: 1190 bytes --]

Hi Ludo,

Ludovic Courtès <ludo@gnu.org> writes:

> Hello comrades!
>
> Timothy Sample <samplet@ngyro.com> skribis:
>
>> [...]
>>
>> From aedc745a3f9765ae00dc61a59fa53d22a458551b Mon Sep 17 00:00:00 2001
>> From: Timothy Sample <samplet@ngyro.com>
>> Date: Sat, 15 Dec 2018 23:17:46 -0500
>> Subject: [PATCH] environment: Print command name on execlp error.
>>
>> Fixes <https://bugs.gnu.org/33755>.
>>
>> * guix/scripts/environment.scm (launch-environment): When execlp fails,
>> include the command name in the error message.
>
> Another option would be to do:
>
>   (set! execl
>     (error-reporting-wrapper …))
>
> in (guix ui), as done for a few other procedures that have the same
> issue.
>
> WDYT?

Aha!  I didn’t know about “error-reporting-wrapper”.  I think this makes
sense.  It fixes the same issue in the container script, too.  I’ve
attached an updated patch.

I had to modify “error-reporting-wrapper” to deal with the fact that
“execlp” takes a variable number of arguments.  I tested it and it works
for the old use-case as well as the new.  On whether or not it works
stylistically, I defer to you.


-- Tim


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ui-Report-file-names-in-system-error-exceptions-from.patch --]
[-- Type: text/x-patch, Size: 1693 bytes --]

From 428b80973026909c915e1f33d4509e82f66355e3 Mon Sep 17 00:00:00 2001
From: Timothy Sample <samplet@ngyro.com>
Date: Sun, 16 Dec 2018 23:12:13 -0500
Subject: [PATCH] ui: Report file names in 'system-error' exceptions from
 'execlp'.

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

* guix/ui.scm (apply-formals): New macro.
(execlp): New error-reporting wrapper.
---
 guix/ui.scm | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 60636edac..148c18103 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -502,14 +502,19 @@ General help using GNU software: <http://www.gnu.org/gethelp/>"))
            (list (strerror (car errno)) file)
            (list errno))))
 
-(define-syntax-rule (error-reporting-wrapper proc (args ...) file)
+(define-syntax apply-formals
+  (syntax-rules ()
+    ((_ proc (args ...)) (proc args ...))
+    ((_ proc (arg1 args ... . rest)) (apply proc arg1 args ... rest))))
+
+(define-syntax-rule (error-reporting-wrapper proc formals file)
   "Wrap PROC such that its 'system-error' exceptions are augmented to mention
 FILE."
   (let ((real-proc (@ (guile) proc)))
-    (lambda (args ...)
+    (lambda formals
       (catch 'system-error
         (lambda ()
-          (real-proc args ...))
+          (apply-formals real-proc formals))
         (augmented-system-error-handler file)))))
 
 (set! symlink
@@ -528,6 +533,8 @@ FILE."
 (set! delete-file
   (error-reporting-wrapper delete-file (file) file))
 
+(set! execlp
+  (error-reporting-wrapper execlp (filename . args) filename))
 
 (define (make-regexp* regexp . flags)
   "Like 'make-regexp' but error out if REGEXP is invalid, reporting the error
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#33755: error: execlp: No such file or directory from guix environment
  2018-12-17  4:41             ` Timothy Sample
@ 2018-12-18  9:05               ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2018-12-18  9:05 UTC (permalink / raw)
  To: Timothy Sample; +Cc: swedebugia, 33755-done

Hi Timothy,

Timothy Sample <samplet@ngyro.com> skribis:

> Aha!  I didn’t know about “error-reporting-wrapper”.  I think this makes
> sense.  It fixes the same issue in the container script, too.  I’ve
> attached an updated patch.
>
> I had to modify “error-reporting-wrapper” to deal with the fact that
> “execlp” takes a variable number of arguments.  I tested it and it works
> for the old use-case as well as the new.  On whether or not it works
> stylistically, I defer to you.

I like it.  :-)

> From 428b80973026909c915e1f33d4509e82f66355e3 Mon Sep 17 00:00:00 2001
> From: Timothy Sample <samplet@ngyro.com>
> Date: Sun, 16 Dec 2018 23:12:13 -0500
> Subject: [PATCH] ui: Report file names in 'system-error' exceptions from
>  'execlp'.
>
> Fixes <https://bugs.gnu.org/33755>.
>
> * guix/ui.scm (apply-formals): New macro.
> (execlp): New error-reporting wrapper.

Applied, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-12-18  9:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-15  7:09 bug#33755: error: execlp: No such file or directory from guix environment swedebugia
2018-12-15  9:40 ` Julien Lepiller
2018-12-15 18:18   ` Timothy Sample
2018-12-15 18:35     ` Timothy Sample
2018-12-15 19:38       ` Danny Milosavljevic
2018-12-16  4:26         ` Timothy Sample
2018-12-16 16:05           ` Ludovic Courtès
2018-12-17  4:41             ` Timothy Sample
2018-12-18  9:05               ` Ludovic Courtès

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.