Behavior of tramp-own-remote-path

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Behavior of tramp-own-remote-path

Augusto Stoffel
I've recently posted a question on Stack Exchange about the way Tramp
sets the PATH [1].  I would set tramp-remote-path to the value
'(tramp-own-remote-path) but Tramp would still not make the PATH
identical to what I get in a direct ssh login.

The problem, it turns out, was due to my PATH being set up in
~/.bashrc instead of ~/.profile.  More specifically, Tramp inquires
the remote machine's PATH with the command

    /bin/sh -l -c 'echo $PATH'

which, I assume, will run some of the /etc/profile.d scripts for a
second time.  As a side effect, some low priority entries of PATH got
pushed to the front.

I wonder if there is something against querying the PATH with the
command

    /bin/echo $PATH

This would have at least the advantage of making the path set-up
more predictable.

Best regards,
Augusto

[1] https://emacs.stackexchange.com/questions/62306/



Reply | Threaded
Open this post in threaded view
|

Re: Behavior of tramp-own-remote-path

Michael Albinus
Augusto Stoffel <[hidden email]> writes:

Hi Augusto,

I'm sorry to reply such late, but there was Xmas, and I had also to
release Tramp 2.5.0.

> I've recently posted a question on Stack Exchange about the way Tramp
> sets the PATH [1].  I would set tramp-remote-path to the value
> '(tramp-own-remote-path) but Tramp would still not make the PATH
> identical to what I get in a direct ssh login.
>
> The problem, it turns out, was due to my PATH being set up in
> ~/.bashrc instead of ~/.profile.  More specifically, Tramp inquires
> the remote machine's PATH with the command
>
>    /bin/sh -l -c 'echo $PATH'
>
> which, I assume, will run some of the /etc/profile.d scripts for a
> second time.  As a side effect, some low priority entries of PATH got
> pushed to the front.

Not really. In recent Tramp versions, it calls what is set in connection
property "remote-shell" if set. If it is "/usr/bin/bash", that is
called. "/bin/sh" is just the fallback.

> I wonder if there is something against querying the PATH with the
> command
>
>    /bin/echo $PATH
>
> This would have at least the advantage of making the path set-up
> more predictable.

Tramp has a long tradition to mistrust $PATH on a remote machine, many
bug reports tell about. So instead of not knowing what is set there in
which shell, it allows you to say exactly what you want. If you want
bash, say it via the "remote-shell" connection property. This protects
you also yourself against different login shells on different machines,
which you don't remember.

> Best regards,
> Augusto

Best regards, Michael.