From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#71655: Eshell external commands do not work under GNU Emacs for Windows Date: Wed, 19 Jun 2024 22:30:00 +0300 Message-ID: <86tthoohmv.fsf@gnu.org> References: <86y170oifx.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4710"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71655@debbugs.gnu.org, james@literate-devops.io To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 19 21:31:20 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sK11c-00011e-8o for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Jun 2024 21:31:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK11J-00075H-3u; Wed, 19 Jun 2024 15:31:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sK11G-00072M-VH for bug-gnu-emacs@gnu.org; Wed, 19 Jun 2024 15:30:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK11G-0002im-NC for bug-gnu-emacs@gnu.org; Wed, 19 Jun 2024 15:30:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sK11K-0004yX-23 for bug-gnu-emacs@gnu.org; Wed, 19 Jun 2024 15:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Jun 2024 19:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71655 X-GNU-PR-Package: emacs Original-Received: via spool by 71655-submit@debbugs.gnu.org id=B71655.171882541819033 (code B ref 71655); Wed, 19 Jun 2024 19:31:02 +0000 Original-Received: (at 71655) by debbugs.gnu.org; 19 Jun 2024 19:30:18 +0000 Original-Received: from localhost ([127.0.0.1]:56172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK10b-0004wu-7L for submit@debbugs.gnu.org; Wed, 19 Jun 2024 15:30:17 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:37788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK10Y-0004wc-Vh for 71655@debbugs.gnu.org; Wed, 19 Jun 2024 15:30:15 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sK10Q-0002cS-7c; Wed, 19 Jun 2024 15:30:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=ZL6xzqOaR3VhORPCcX5hyz4FhvkEJ8L8WUrVbRg91Ww=; b=ApxQJdBYhNsku6udvYEj IKce/U7un9r1SUF4qaWZFSQdJUGY/0e1zEMtye1qDELWF/jqHfw4wUkrNXpD4gujnZuzxB25Saqmd 2bAh9pgyJZ+tF0JU4mw1TSW7stLvry3o8HiM7f0ds5Pxtx4LFzOgzCJMoEmNJokgwq6aDjUcBMYoq V46ra/EgRUMhDsOrf/pH0UsbSqh6oR6JAhvY+NIGQQd9XPFP2nTtl5GCsQYt7Vme2FEy5Z2mOB46g 6BRnlwwopfqTO2LCgQNaXk3kOzroFtU1yColVkdqlO2eQSxHC/EeMUZRmhvoF5g/cBQqtf6c52KpM 4e3Jv3Qtpq0fYA==; In-Reply-To: <86y170oifx.fsf@gnu.org> (message from Eli Zaretskii on Wed, 19 Jun 2024 22:12:34 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287503 Archived-At: > Cc: 71655@debbugs.gnu.org > Date: Wed, 19 Jun 2024 22:12:34 +0300 > From: Eli Zaretskii > > (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 () #)() funcall(#f(compiled-function () #)) (let ((eshell-this-command-hook '(ignore))) (funcall '#f(compiled-function () #))) eval((let ((eshell-this-command-hook '(ignore))) (funcall '#f(compiled-function () #)))) 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 () #)() funcall(#f(compiled-function () #)) (let ((eshell-current-handles '[nil (((t) . 2) t) (((t) . 2) t)])) (funcall '#f(compiled-function () #))) eval((let ((eshell-current-handles '[nil ((... . 2) t) ((... . 2) t)])) (funcall '#f(compiled-function () #)))) 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 () #)() funcall(#f(compiled-function () #)) (let ((eshell-current-handles '[nil (((t) . 2) t) (((t) . 2) t)]) (eshell-current-subjob-p 'nil)) (funcall '#f(compiled-function () #))) eval((let ((eshell-current-handles '[nil ((... . 2) t) ((... . 2) t)]) (eshell-current-subjob-p 'nil)) (funcall '#f(compiled-function () #)))) 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))