From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#57556: 28.1; Eshell not finding executables in PATH when tramp-integration loaded Date: Fri, 07 Oct 2022 20:28:56 +0200 Message-ID: <87fsfzh4if.fsf@gmx.de> References: <87h715j5gy.fsf@gmx.de> <0480c49e-75da-68c4-d255-242ff65323fe@gmail.com> <87czbsjyby.fsf@gmx.de> <877d1vthto.fsf@gmx.de> <871qrrffzj.fsf@gmx.de> <2d1f17a5-554d-1b1f-7bcb-52e3839d9d0c@gmail.com> <87wn9iehl1.fsf@gmx.de> <00448968-481d-9bdd-b0c8-7bc3d04e5d60@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30552"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 57556@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 07 20:33:36 2022 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 1ogsAB-0007oB-SS for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Oct 2022 20:33:35 +0200 Original-Received: from localhost ([::1]:49828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogsAA-0007Ca-CZ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Oct 2022 14:33:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogs6l-0005cI-6u for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 14:30:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogs6k-0000hT-Nh for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 14:30:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogs6k-00022j-BY for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 14:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Oct 2022 18:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57556 X-GNU-PR-Package: emacs Original-Received: via spool by 57556-submit@debbugs.gnu.org id=B57556.16651673517769 (code B ref 57556); Fri, 07 Oct 2022 18:30:02 +0000 Original-Received: (at 57556) by debbugs.gnu.org; 7 Oct 2022 18:29:11 +0000 Original-Received: from localhost ([127.0.0.1]:37351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogs5u-00021F-Th for submit@debbugs.gnu.org; Fri, 07 Oct 2022 14:29:11 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:41191) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogs5t-00020z-8L for 57556@debbugs.gnu.org; Fri, 07 Oct 2022 14:29:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1665167340; bh=UiaI1EUJId4wuqwEi8Xk1dW4RK6o2PZ93PrPLkkzQMM=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=BWrkwMk9nm6BK3QJg1l0pGJ6qO4ao3Bkm3SlSHZPS3k0WFEEiqvpejfUhvUN5Sqsw ZcnW+Rq+NCSTSGg5Yed2NYTeL6T2mqMk8NDD/sQs+5agrpFQzJNfDPyaMLFoYBZxY6 pOtU8oGMG/WIYQKQdj60ynCsbJmaU7lu5XGoAB1c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([213.220.148.171]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N8GMq-1pBiiB40Ku-014EVE; Fri, 07 Oct 2022 20:29:00 +0200 In-Reply-To: <00448968-481d-9bdd-b0c8-7bc3d04e5d60@gmail.com> (Jim Porter's message of "Thu, 6 Oct 2022 20:19:26 -0700") X-Provags-ID: V03:K1:Ye6IfZ/R+0RSiOoHz2JyA+8eWwCeRitWbZX0qrgZm2VvVfA5Xpy WRsooJgKLK6wNpczWNvm0U1OVUfBZF+QlNjszfnvnMnPV274mt65mdNTujBbDcXHoqgsZh6 PZs7/SLcskzTaHei9k51cuGMciP0fayMSJTr9nsp/sl8LcvB2nCoukdw5E6aYX7+1FDJqRs vH+vvjc3UKoPaf9q74lHg== X-UI-Out-Filterresults: notjunk:1;V03:K0:J4OuJ7fLn4c=:WOIic7w3/7AiQ//cOLRmr2 TfmYLxjwNh/yd2WMhi7vf0KuG+Y0h+FOaRz2ycnxWCad0CY04tUatkGtKc/YReMzv8+2NLnc5 NKbN87K0LrHMnDyAhQREC4ZiqDg7DvuB5JZpL0rM95tOogywgqn7DNUi6QzdU6/NgEs3m2iK3 bYCIqsDvgrwOGp/TjlM96kFlBF3Snrp6fWi3pwZviGSMO5gId861wdiIswwSILIPgTStn8Wi9 N6inGjkxGZy5Ut6ulFMCCAa+2nUuC1ir/wsxYd9kMhNpCh1dYrXybz+Mm6DGV0l0J+8q3gYhX bLYuej8kkkVZDZPMvIGE0kVHrMBMZeCAEIwX0Yt2Br9L4mAq3MtjBk2hjAQx+tvyun7qB2dqg I/pk497eI5yXZV8JsYzrTXDh4f95n/EmBGxlEzjT5c95K25ZlEIs6HF45d4E9E2Cggb6Neqsp FfM5yVdCQ/0jiq//5eZtGTaCDdUk2qpkWNQ/n7WmI9PChTzc6U7KceeaRI3dKhA6Mjqe6rV7o PaQmoKF/YSzEzXzciw4dJCTFY2svmrYi5uyc+QRUlNKHZV4uRb5bbBqdoYN4snAnBDwslWR3O PimuvWlcGSoGzOtcmzMxi6ibNgVzT/OUhKWejb8CHIqVNQxCgJwhYZfXZQ+VDFfzcyhBjSehr DXeZlGNiAv3TymYV7dKd0muJmNCGOqCFJfJHv4qHAbQPzJ/YY4E+Barm3T8me7UvGD9AITF2J Cbj5JwMcoAeq1YLxtcxK03tYdv9434DWBU11EzeReLJq89520S1JRUZ9YblZWb1mtE1HsHy6 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" Xref: news.gmane.io gmane.emacs.bugs:244837 Archived-At: --=-=-= Content-Type: text/plain Jim Porter writes: Hi Jim, Thanks your the example file, it is a pleasure to work on something like this! > Hmm, I've tried this a few different ways, and I haven't been able to > get it to work the way it should. Maybe I'm just missing something? > > Attached is a minimal test case I've extracted to show the issue I'm > having. It seems the problem is that, while I can update the path in > 'eshell-set-path' with no problem, when I call 'eshell-get-path' > again, 'hack-connection-local-variables-apply' resets > 'eshell-path-env-list' to nil, so the modified path is lost. > > Do you have any ideas about what I'm doing wrong? Or maybe > connection-local variables aren't supposed to be used this way. All > the documentation I see on them involves setting variables to constant > values, not updating them in-place over the life of a program. Well, your example code has some problems: - connection-local-criteria-for-default-directory returns nil for a local default directory. In order to handle this case, I have added eshell-connection-local-criteria-for-default-directory. - You cannot use the same profile for different criteria, unless you intend the same settings. Therefore, I have added eshell-connection-local-profile. - If you change settings in eshell-get-path or eshell-set-path, you must tell this to the connection-local variables machinery. I've extended both functions accordingly. Now your ert test passes for me. Changed connection-local.el added. Best regards, Michael. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=connection-local.el ;;; -*- lexical-binding:t -*- ;; Run these tests with: ;; emacs -Q --batch -l ~/etc/emacs/connection-local.el \ ;; --eval '(ert-run-tests-batch-and-exit t)' (require 'tramp) (require 'ert) (require 'ert-x) (defvar-local eshell-path-env-list nil) (defsubst eshell-connection-local-criteria-for-default-directory () (or (connection-local-criteria-for-default-directory 'eshell) '(:application eshell :machine local))) (defsubst eshell-connection-local-profile () (intern (concat "eshell-connection-local-profile-" (or (file-remote-p default-directory) "local")))) ;; Initial values. (connection-local-set-profile-variables 'eshell-connection-local-profile '((eshell-path-env-list . nil))) (connection-local-set-profiles '(:application eshell) 'eshell-connection-local-profile) (defun eshell-get-path () "Return $PATH as a list." (let ((enable-connection-local-variables t) connection-local-variables-alist) ;; I'm not sure this is needed. (hack-connection-local-variables-apply (eshell-connection-local-criteria-for-default-directory)) (prog1 (or eshell-path-env-list ;; If not already cached, get the path from `exec-path', ;; removing the last element, which is `exec-directory'. (setq eshell-path-env-list (butlast (exec-path)))) ;; Set connection-local-variable. (connection-local-set-profile-variables (eshell-connection-local-profile) `((eshell-path-env-list . ,eshell-path-env-list))) (connection-local-set-profiles (eshell-connection-local-criteria-for-default-directory) (eshell-connection-local-profile))))) (defun eshell-set-path (path) "Set the Eshell $PATH to PATH. PATH can be either a list of directories or a string of directories separated by `path-separator'." (let ((enable-connection-local-variables t) connection-local-variables-alist) ;; I'm not sure this is needed. (hack-connection-local-variables-apply (eshell-connection-local-criteria-for-default-directory)) (prog1 (setq eshell-path-env-list (if (listp path) path ;; Don't use `parse-colon-path' here, since we don't want ;; the additonal translations it does on each element. (split-string path (path-separator)))) ;; Set connection-local-variable. (connection-local-set-profile-variables (eshell-connection-local-profile) `((eshell-path-env-list . ,eshell-path-env-list))) (connection-local-set-profiles (eshell-connection-local-criteria-for-default-directory) (eshell-connection-local-profile))))) (ert-deftest esh-var-test/path-var/preserve-across-hosts () "Test that $PATH can be set independently on multiple hosts." ;; Test the initial value of the local $PATH. (should (equal (eshell-get-path) (butlast (exec-path)))) ;; Set the local $PATH and make sure it retains the value we set. (should (equal (eshell-set-path "/local/path") '("/local/path"))) (should (equal (eshell-get-path) '("/local/path"))) ; FAIL (let ((default-directory ert-remote-temporary-file-directory)) ;; Test the initial value of the remote $PATH. (should (equal (eshell-get-path) (butlast (exec-path)))) ;; Set the remote $PATH and make sure it retains the value we set. (should (equal (eshell-set-path "/remote/path") '("/remote/path"))) (should (equal (eshell-get-path) '("/remote/path")))) ; FAIL ;; Make sure we get the local $PATH we set above. (should (equal (eshell-get-path) '("/local/path"))) ; FAIL ;; Make sure we get the remote $PATH we set above. (let ((default-directory ert-remote-temporary-file-directory)) (should (equal (eshell-get-path) '("/remote/path"))))) ; FAIL --=-=-=--