GNU bug report logs -
#61926
29.0.60; [PATCH] Make tramp-remote-path behave like exec-path
Previous Next
Full log
View this message in rfc822 format
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.
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ão
commit c9d577b9ede6192af6db47442ab9709127e39fb2
Author: João Távora <joaotavora <at> gmail.com>
Date: Wed Mar 1 11:03:23 2023 +0000
Tramp: flush configuration if tramp-remote-path changed
* 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" "")))
+(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
This bug report was last modified 125 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.