I'm trying to load environment modules from a non-interactive remote session, and set environment variables accordingly.
For example, in my bashrc I normally call
module load /path/to/cmake/3.x.x
and when I run "cmake --version" from a login shell I'll see
However, when I run this with a non-interactive remote session, I see cmake v2.xxx as the deafult.
ssh me@machine 'cmake --version'
In order to get around this, I've tried to update my /etc/ssh/sshd_config to "PermitUserEnvironment yes"
Inside my ~/.ssh/environment file I'm able to set environment variables accordingly, and update my $PATH. This works, and when running commands remotely over ssh I can see my path is updated. i.e.
ssh me@machine 'echo $PATH'
I've also created a ~/.ssh/rc file which I can confirm DOES get called. However, even though I've put the same "module load /path/to/cmake/3.x.x" I still see it loading v2. The same goes if I update and export my PATH inside my .ssh/rc. It updates, but it seems it's applying it to a different shell than the one being used remotely.
I don't understand why ~/.ssh/environment modifies things for the current shell, but ~/.ssh/rc modifies things for seemingly a different shell.
Any ideas on how I can use environment modules remotely?