From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#61926: 29.0.60; [PATCH] Make tramp-remote-path behave like exec-path Date: Fri, 03 Mar 2023 00:19:50 +0000 Message-ID: <87y1oe7kk9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32047"; mail-complaints-to="usenet@ciao.gmane.io" Cc: michael.albinus@gmx.de To: 61926@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 03 01:19:24 2023 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 1pXt8u-0008C9-4R for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Mar 2023 01:19:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXt8a-0008Ug-P6; Thu, 02 Mar 2023 19:19:04 -0500 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 1pXt8Y-0008TW-TC for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 19:19:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXt8Y-0006HE-9v for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 19:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pXt8X-0007TG-Ss; Thu, 02 Mar 2023 19:19:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: michael.albinus@gmx.de, bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 Mar 2023 00:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61926 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: michael.albinus@gmx.de Original-Received: via spool by submit@debbugs.gnu.org id=B.167780268328630 (code B ref -1); Fri, 03 Mar 2023 00:19:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Mar 2023 00:18:03 +0000 Original-Received: from localhost ([127.0.0.1]:59250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXt7a-0007Ri-Ov for submit@debbugs.gnu.org; Thu, 02 Mar 2023 19:18:03 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:33594) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXt7Z-0007RU-RI for submit@debbugs.gnu.org; Thu, 02 Mar 2023 19:18:02 -0500 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 1pXt7Z-0007VV-D2 for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 19:18:01 -0500 Original-Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXt7X-00069q-Eq for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 19:18:01 -0500 Original-Received: by mail-wm1-x330.google.com with SMTP id p26so654885wmc.4 for ; Thu, 02 Mar 2023 16:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677802677; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=9tLDlHDahGAln+923qmH9CUfspf2zYQ1gbu6QKbeoAM=; b=jE+pRLn+D8UhNa7Ar7TjL8JUy0vc1uW/XW7F/LKWSGKBzzgDSPxQoP/9IOfBG7tNzb +Aw9PJ+dG8mJPv8Bbp4yajAdA1GKHZInRxMjM+nN3O5Deu3ocjKItXVnfTApcRG5euNR RBc3Zresu3RSqHVP0cqZKn0LuuD46IYwyI801cj18dvn4ij4dADjSTk1LFZHCustulHh 5dafNEzARL/QVYRhpe2ZjE9Yl8KMMYDDHQSkOcdx0PXA5p6Cw+dS76Ksm/cB8SYv3kOw qo/sN7s4F0jocscYgy+IVwSPYy1sGTwcwkUCnFsZytI3RvFp3vmuDrqoXvlCw3IFyC4J HWUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677802677; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9tLDlHDahGAln+923qmH9CUfspf2zYQ1gbu6QKbeoAM=; b=bjKurDvDiL4lftOx07oKGYbh30z07G9r73VJMJy9PfPU45CD8fYbR0t8cMvoRXXMHW U/C7TJt52wKFdhLzF4JPrbgaPYiaHiCUoHmfHdnoj/kXY4zB14mVqWUH3ocrlCbCAPke f05eSVAbyCx+meZfJiadPsmgfDuxasTeIEI2RILVdFnyQXyLbE9LvBUKC8JKwBwo3Pkl w8SNQHtZVCD29tXQUCf/Qkw+LKIa6hy86YHjnsP7ggojBRQ1Cz2cUPbHgSPyIIp9g3hk YxL1bggUMKpWSh7wLRiSptiDrTx261qUBdzRHMHVDPvnAvmR3WNJfivjMXDA+l8Nsicg W2Aw== X-Gm-Message-State: AO0yUKXUA+O1giQq61u+xAfhnB9WrxSfmpi/fn7Hz1JAihot0WVtRd6k 0uCHXgpPvXwOE9VlG5YsQ5pMKXxqKF4= X-Google-Smtp-Source: AK7set92eiq5PadD6pYxas3t0nBR88nXagO0LV+RhbT73I1bjye47OdQ/ZnVtgo4+asTgo/bJlwAYw== X-Received: by 2002:a05:600c:329c:b0:3eb:3912:5ae9 with SMTP id t28-20020a05600c329c00b003eb39125ae9mr8477054wmp.24.1677802677005; Thu, 02 Mar 2023 16:17:57 -0800 (PST) Original-Received: from krug (87-196-72-142.net.novis.pt. [87.196.72.142]) by smtp.gmail.com with ESMTPSA id r8-20020a5d4e48000000b002c5d3f0f737sm654057wrt.30.2023.03.02.16.17.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 16:17:56 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=joaotavora@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:257186 Archived-At: Hi maintainers, Michael, This started in bug#61748. There we discovered that while something like this works and will correctly find '/home/user/bin/myscript' ~/Source/Emacs/emacs/src/emacs -Q --batch \ -l tramp \ --eval '(add-to-list (quote tramp-remote-path) "~/bin")' \ $REMOTE_FILE \ --eval '(message "%s" (executable-find "myscript" t))' This subtly different incantation will _not_ work: ~/Source/Emacs/emacs/src/emacs -Q --batch \ -l tramp \ $REMOTE_FILE \ --eval '(add-to-list (quote tramp-remote-path) "~/bin")' \ --eval '(message "%s" (executable-find "myscript" t))' This is because of a caching behaviour in tramp-get-remote-path. The patch after my sig solves the problem: the above two incantations produce the same value. It will prevent confusion among users (as I was) about the what seemed like unstable behaviour from executble-find and program invocation. Very few Emacs variables, if any, require a separate command (here M-x tramp-cleanup-all-connections) to be issued after the variables value is set. This variable needn't belong to that group.=20=20 There is a discussion about this caching somewhat deep in the Tramp manual. But I think it would be much nicer if simple things like this worked out of the box, allowing users to experiment with value for `tramp-remote-path' via M-: (setq ... ) or some other variable-setting method, until they get it right. Changing this variable's value doesn't alter the remote value of the PATH environment variable, much like changing exec-path locally doesn't change the local PATH environment variable. Jo=C3=A3o commit c9d577b9ede6192af6db47442ab9709127e39fb2 Author: Jo=C3=A3o T=C3=A1vora Date: Wed Mar 1 11:03:23 2023 +0000 Tramp: flush configuration if tramp-remote-path changed =20=20=20=20 * lisp/net/tramp-sh.el (tramp-last-used-remote-path): New variable. (tramp-get-remote-path): Use it to decide to flush. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index ec8437176db..29d2dda6829 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -5571,10 +5571,18 @@ tramp-check-remote-uname "Check whether REGEXP matches the connection property \"uname\"." (string-match-p regexp (tramp-get-connection-property vec "uname" ""))) =20 +(defvar tramp-last-used-remote-path nil) + (defun tramp-get-remote-path (vec) "Compile list of remote directories for PATH. Nonexistent directories are removed from spec." (with-current-buffer (tramp-get-connection-buffer vec) + (when (not (equal tramp-last-used-remote-path tramp-remote-path)) + ;; If user has tweaked `tramp-remote-path', flush any caches + ;; bug#61748. + (dolist (v (list vec (tramp-get-process vec))) + (tramp-flush-connection-property v "remote-path"))) + (setq tramp-last-used-remote-path tramp-remote-path) ;; Expand connection-local variables. (tramp-set-connection-local-variables vec) (with-tramp-connection-property