4.16 How TRAMP finds and uses programs on the remote host

TRAMP requires access to and rights to several commands on remote hosts: ls, test, find and cat.

Besides there are other required programs for Inline methods and External methods of connection.

To improve performance and accuracy of remote file access, TRAMP uses perl (or perl5) and grep when available.

User Option: tramp-remote-path

tramp-remote-path specifies which remote directory paths TRAMP can search for How TRAMP finds and uses programs on the remote host.

TRAMP uses standard defaults, such as /bin and /usr/bin, which are reasonable for most hosts. To accommodate differences in hosts and paths, for example, /bin:/usr/bin on Debian GNU/Linux or /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/developerstudio12.6/bin on Solaris, TRAMP queries the remote host with getconf PATH and updates the symbol tramp-default-remote-path.

For instances where hosts keep obscure locations for paths for security reasons, manually add such paths to local .emacs as shown below for TRAMP to use when connecting.

(add-to-list 'tramp-remote-path "/usr/local/perl/bin")

Another way to find the remote path is to use the path assigned to the remote user by the remote host. TRAMP does not normally retain this remote path after login. However, tramp-own-remote-path preserves the path value, which can be used to update tramp-remote-path.

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

Note that this works only if your remote /bin/sh shell supports the login argument ‘-l’.

tramp-remote-path can also be set per host via connection-local variables. You could define your own search directories like this:

(connection-local-set-profile-variables 'remote-path-with-bin
   '((tramp-remote-path . ("~/bin" tramp-default-remote-path))))

(connection-local-set-profile-variables 'remote-path-with-apply-pub-bin
   '((tramp-remote-path . ("/appli/pub/bin" tramp-default-remote-path))))

(connection-local-set-profiles
   '(:application tramp :machine "randomhost") 'remote-path-with-bin)

(connection-local-set-profiles
   '(:application tramp :user "anotheruser" :machine "anotherhost")
     'remote-path-with-apply-pub-bin)

When remote search paths are changed, local TRAMP caches must be recomputed. To force TRAMP to recompute afresh, call M-x tramp-cleanup-this-connection RET or friends (see Cleanup remote connections).