Hacker News new | ask | show | jobs
by eslaught 4710 days ago
The problem is that running an MPI program on a remote node starts a new non-interactive SSH session. That SSH session has no parent login session, so it won't inherit environment variables from any session that read the .profile file. And because the SSH login is non-interactive, the only file that the shell inside the SSH session reads is .bashrc.

Sure, you could source .profile manually, but this is awkward to code inside an MPI application. In addition, this will cause .bashrc to get sourced twice, because your shell already read .bashrc when it started the SSH session. Hopefully your .bashrc is idempotent, but even so, it feels wrong to have to read .bashrc twice.

Try this on a remote server:

    remote:~$ cat .profile
    echo "read .profile"

    echo "sourcing .bashrc from .profile"
    source ~/.bashrc
    remote:~$ cat .bashrc
    echo "read .bashrc"
And then from your local machine:

    local:~$ ssh remote
    read .profile
    sourcing .bashrc from .profile
    read .bashrc
    local:~$ ssh remote -k true
    read .bashrc