I was upgrading my Emacs from 26.3 to 29.0.91 (I know, a long jump), and found some of my "kubel" tramp file path no longer gives me the correct home directory. The reason is in tramp "kubel" method, the "user name" is actually the container name of a k8 pod, like this: kubectl:container-name@my-k8-pod-40051cef-63b8-cf05-7414-56a0b1537acd-1.6h6mwp Current code will return "~container-name" as the home directory, which is wrong.
kubel is a package here: https://github.com/abrochard/kubel I modified the function directly, basically giving it a retry with a blank user name when the returned value does not make sense. Mine probably is just a hack. I hope you agree this is an issue and a proper fix can be made. Thanks. Warren (defun tramp-sh-handle-get-home-directory (vec &optional user) "!!!!!!!! Modified on Emacs 29.1 by !!!!!!!!!!! The remote home directory for connection VEC as local file name. If USER is a string, return its home directory instead of the user identified by VEC. If there is no user specified in either VEC or USER, or if there is no home directory, return nil." (let ((result (when (tramp-send-command-and-check vec (format "echo %s" (tramp-shell-quote-argument (concat "~" (or user (tramp-file-name-user vec)))))) (with-current-buffer (tramp-get-buffer vec) (goto-char (point-min)) (buffer-substring (point) (line-end-position)))))) ;; if the result starts with "~", this is an invalid user, just re-call without user specified. (if (string= (substring result 0 1) "~") (tramp-sh-handle-get-home-directory vec "") result)))