7

I have set up custom $PATH in my ~/.bash_profile on a remote machine (for programs installed user-locally by nix and cabal).

I use eshell and tramp to issue commands on the remote machine (cd /remotehost:somedir; then commands). (I chose this method instead of the common SSH-sessions in a terminal primarily because I'm using a bad connection and SSH-sessions get interrupted very often, so I can't count on being able to login, cd, and issue a command before the connection is interrupted.)

Unfortunately, my custom PATH is not honored in this situation, and some of the programs are not found.

What would be the nicest way to solve this problem?

5

This question has been already answered by rekado (thanks!) (as a reply to another more general question about eshell):

You can configure TRAMP to respect the PATH variable on the remote machine (for remote eshell sessions) by adding 'tramp-own-remote-path to the list 'tramp-remote-path:

(add-to-list 'tramp-remote-path 'tramp-own-remote-path)

By default, eshell will not adopt the remote PATH settings.

As for other environment variables, there is no special approach as for PATH: one can set them through tramp-remote-process-environment (as documented in https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-processes.html):

(add-to-list 'tramp-remote-process-environment
              (format "DISPLAY=%s" (getenv "DISPLAY")))

and I don't know of a way that would read the ones set in the remote ~/.bash_profile. So you need to repeat them in this variable on the local side in Emacs as a workaround, which is not totally convenient because different remote hosts might need different values.

As for EDITOR specifically, of course, doing it with with-editor would be more convenient and appropriate.

  • 1
    I don't see that this works. Perhaps, that's because I set and export a custom PATH in ~/.bash_profile (contrary to ~/.profile) which I have seen in some docs concerning these tramp-* vars... – imz -- Ivan Zakharyaschev Jan 26 '15 at 20:01
  • 1
    This was fixed in Tramp last December. Try the development version of Tramp. – Michael Albinus Jan 27 '15 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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