1

Tramp is very tenacious in overriding the PATH setting of a remote machine. How can I completely disable this, so that Tramp's PATH is identical to what I get when I manually log in with ssh on the terminal?

The ~/.bashrc in my remote machine looks as follows:

export PATH1=$PATH
# activate some Python virtualenvs, etc...
export PATH2=$PATH

I want the final PATH to be PATH2. The closest I can get to that is when setting tramp-remote-path to the value '(tramp-own-remote-path), in which case my PATH ends up being identical to PATH1. (I'm checking this by doing M-x compile RET env RET while editing a remote file.)

One interesting solution (with other applications as well) would be to stipulate, as a directory or connection-local variable, an additional rc file on the remote machine that is sourced every time Tramp connects. Is this possible at all?

2 Answers 2

1

Short solution: add all PATH-related settings to ~/.profile instead of ~/.bashrc, and make sure the former is sh-compatible.

0

Interesting idea. I have added it to the TODO list of Tramp. If you want to discuss further, I invite you to the <[email protected]> mailing list. SX is not intended for longer discussions.

2
  • Do you consider this just a bug, or would you like more details about my motivation here? In the latter case, I'd be happy to discuss it on the mailing list.
    – Augusto
    Dec 19, 2020 at 18:51
  • Tramp's path-munging was killing my ability to use M-x compile to build anything on the remote machine because it was nuking the path to gcc etc (I use devtoolset-n on CentOS to get gcc-n for different versions). My sledgehammer approach in emacs-27.2 was to put this in my .emacs - (eval-after-load "tramp-sh" '(defun tramp-set-remote-path(vec))) - BOOM!
    – kbro
    May 26, 2021 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.