GNU bug report logs - #71655
Eshell external commands do not work under GNU Emacs for Windows

Previous Next

Package: emacs;

Reported by: James Hilling <james <at> literate-devops.io>

Date: Wed, 19 Jun 2024 18:50:02 UTC

Severity: normal

Merged with 74150

Done: Jim Porter <jporterbugs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: 71655 <at> debbugs.gnu.org, james <at> literate-devops.io
Subject: bug#71655: Eshell external commands do not work under GNU Emacs for Windows
Date: Wed, 19 Jun 2024 22:30:00 +0300
> Cc: 71655 <at> debbugs.gnu.org
> Date: Wed, 19 Jun 2024 22:12:34 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
>   (Eshell) $ ls -l C:/Users/MyUser/AppData/Local/Microsoft/WindowsApps/winget.exe
> 
> What do you see?  Does what you see explain the error?
> 
> I think this page explains what is going on:
> 
>   https://stackoverflow.com/questions/58296925/what-is-zero-byte-executable-files-in-windows

That being said, both M-! and call-process succeed in invoking this
"program" okay, so there's something Eshell does that gets in the way.
Here's the backtrace from the error:

  Debugger entered--Lisp error: (file-error "Opening input file" "Invalid argument" "C:/Users/EliZ/AppData/Local/Microsoft/WindowsApps/winget.exe")
    insert-file-contents("C:/Users/EliZ/AppData/Local/Microsoft/WindowsApps/winget.exe" nil 0 256 nil)
    insert-file-contents-literally("C:/Users/EliZ/AppData/Local/Microsoft/WindowsApps/winget.exe" nil 0 256)
    eshell-script-interpreter("C:/Users/EliZ/AppData/Local/Microsoft/WindowsApps/winget.exe")
    eshell-find-interpreter("winget" ("--help") nil)
    eshell-connection-local-command("winget" ("--help"))
    eshell-external-command("winget" ("--help"))
    eshell-plain-command("winget" ("--help"))
    eshell-named-command("winget" ("--help"))
    eval((eshell-named-command '"winget" '("--help")))
    eshell-do-eval((eshell-named-command '"winget" '("--help")) nil)
    eshell-do-eval((unwind-protect (eshell-named-command '"winget" '("--help")) (mapc #'funcall eshell-this-command-hook)) nil)
    #f(compiled-function () #<bytecode -0x165be7c9ce9ef886>)()
    funcall(#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>))
    (let ((eshell-this-command-hook '(ignore))) (funcall '#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>)))
    eval((let ((eshell-this-command-hook '(ignore))) (funcall '#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>))))
    eshell-do-eval((let ((eshell-this-command-hook '(ignore))) (unwind-protect (eshell-named-command '"winget" '("--help")) (mapc #'funcall eshell-this-command-hook))) nil)
    (condition-case err (eshell-do-eval '(let ((eshell-this-command-hook '(ignore))) (unwind-protect (eshell-named-command '"winget" '("--help")) (mapc #'funcall eshell-this-command-hook))) nil) ((debug error) (eshell-errorn (error-message-string err)) (eshell-close-handles 1)))
    eval((condition-case err (eshell-do-eval '(let ((eshell-this-command-hook '...)) (unwind-protect (eshell-named-command '"winget" '...) (mapc #'funcall eshell-this-command-hook))) nil) ((debug error) (eshell-errorn (error-message-string err)) (eshell-close-handles 1))))
    eshell-do-eval((condition-case err (eshell-do-eval '(let ((eshell-this-command-hook '...)) (unwind-protect (eshell-named-command '"winget" '...) (mapc #'funcall eshell-this-command-hook))) nil) ((debug error) (eshell-errorn (error-message-string err)) (eshell-close-handles 1))) nil)
    eshell-do-eval((condition-case err (eshell-do-eval '(let ((eshell-this-command-hook '...)) (unwind-protect (eshell-named-command '"winget" '...) (mapc #'funcall eshell-this-command-hook))) nil) ((debug error) (eshell-errorn (error-message-string err)) (eshell-close-handles 1))) nil)
    #f(compiled-function () #<bytecode -0x165be7c9ce9ef886>)()
    funcall(#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>))
    (let ((eshell-current-handles '[nil (((t) . 2) t) (((t) . 2) t)])) (funcall '#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>)))
    eval((let ((eshell-current-handles '[nil ((... . 2) t) ((... . 2) t)])) (funcall '#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>))))
    eshell-do-eval((let ((eshell-current-handles '[nil ((... . 2) t) ((... . 2) t)])) (condition-case err (eshell-do-eval '(let ((eshell-this-command-hook ...)) (unwind-protect (eshell-named-command ... ...) (mapc ... eshell-this-command-hook))) nil) ((debug error) (eshell-errorn (error-message-string err)) (eshell-close-handles 1)))) nil)
    eshell-do-eval((progn (let ((eshell-current-handles '[nil (... t) (... t)])) (condition-case err (eshell-do-eval '(let (...) (unwind-protect ... ...)) nil) ((debug error) (eshell-errorn (error-message-string err)) (eshell-close-handles 1))))) nil)
    eshell-do-eval((unwind-protect (progn (let ((eshell-current-handles '[nil ... ...])) (condition-case err (eshell-do-eval '(let ... ...) nil) ((debug error) (eshell-errorn (error-message-string err)) (eshell-close-handles 1))))) (run-hooks 'eshell-post-command-hook)) nil)
    eshell-do-eval((progn 'nil (unwind-protect (progn (let ((eshell-current-handles '...)) (condition-case err (eshell-do-eval '... nil) ((debug error) (eshell-errorn ...) (eshell-close-handles 1))))) (run-hooks 'eshell-post-command-hook))) nil)
    #f(compiled-function () #<bytecode -0x165be7c9ce9ef886>)()
    funcall(#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>))
    (let ((eshell-current-handles '[nil (((t) . 2) t) (((t) . 2) t)]) (eshell-current-subjob-p 'nil)) (funcall '#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>)))
    eval((let ((eshell-current-handles '[nil ((... . 2) t) ((... . 2) t)]) (eshell-current-subjob-p 'nil)) (funcall '#f(compiled-function () #<bytecode -0x165be7c9ce9ef886>))))
    eshell-do-eval((let ((eshell-current-handles '[nil ((... . 2) t) ((... . 2) t)]) eshell-current-subjob-p) (progn 'nil (unwind-protect (progn (let ((eshell-current-handles ...)) (condition-case err (eshell-do-eval ... nil) (... ... ...)))) (run-hooks 'eshell-post-command-hook)))))
    eshell-resume-eval((nil (let ((eshell-current-handles '[nil (... t) (... t)]) eshell-current-subjob-p) (progn 'nil (unwind-protect (progn (let (...) (condition-case err ... ...))) (run-hooks 'eshell-post-command-hook)))) nil))
    eshell-eval-command((let ((eshell-current-handles '[nil ((... . 2) t) ((... . 2) t)]) eshell-current-subjob-p) (progn 'nil (unwind-protect (progn (let ((eshell-current-handles ...)) (condition-case err (eshell-do-eval ... nil) (... ... ...)))) (run-hooks 'eshell-post-command-hook)))) "winget --help")
    eshell-send-input(nil)
    funcall-interactively(eshell-send-input nil)
    call-interactively(eshell-send-input nil nil)
    command-execute(eshell-send-input)

Jim, why does Eshell want to read the executable file winget.exe?  If
that's because it wants to find the signature by which it will deduce
the interpreter, then doing that for zero-size files is not useful,
and should probably be skipped?

This naïve patch fixes the problem:

diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index 3c4deb3..d9631be 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -247,7 +247,8 @@ eshell-connection-local-command
 		 ;; know the interpreter in that case, therefore the
 		 ;; check is suppressed.
 		 (or (and (stringp command) (file-remote-p command))
-		     (file-remote-p default-directory)))))
+		     (file-remote-p default-directory)
+                     (zerop (file-attribute-size (file-attributes (executable-find command))))))))
     (cl-assert interp)
     (if (functionp (car interp))
 	(apply (car interp) (append (cdr interp) args))





This bug report was last modified 203 days ago.

Previous Next


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