I have installed CMake on my MacBook Pro M1 and have made symbolic link to cmake
in /usr/local/bin
.
I tried different ways to call cmake
and check $PATH
. Here is a report of all cases:
ssh ali@mac cmake
zsh:1: command not found: cmake
ssh ali@mac <<EOF
cmake
EOF
Pseudo-terminal will not be allocated because stdin is not a terminal.
#output from cmake (it works)
ssh ali@mac
cmake
#output from cmake (it works)
ssh ali@mac echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
ssh ali@mac 'echo $PATH'
/usr/bin:/bin:/usr/sbin:/sbin
ssh ali@mac <<EOF
echo $PATH
EOF
Pseudo-terminal will not be allocated because stdin is not a terminal.
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
ssh ali@mac
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
ssh ali@mac which cmake
cmake not found
ssh ali@mac <<EOF
which cmake
EOF
Pseudo-terminal will not be allocated because stdin is not a terminal.
/usr/local/bin/cmake
ssh ali@mac
which cmake
/usr/local/bin/cmake
Running the command ls -l /usr/local/bin/cmake
, no matter direct argument to ssh or heredoc or within ssh connection, gives this output:
lrwxr-xr-x 1 root wheel 42 Mar 25 17:42 /usr/local/bin/cmake -> /Applications/CMake.app/Contents/bin/cmake
The software version on my mac:
sw_vers
ProductName: macOS
ProductVersion: 11.2.1
BuildVersion: 20D75
I can't understand why the result of passing command to ssh is different than passing it with heredoc.
I also set PermitUserEnvironment PATH
in /etc/ssh/sshd_config and restarted the system, it didn't change anything. I didn't create an environment file, because the case that fails to find cmake, already has ./usr/local/bin
in the $PATH
brew install cmake
. That is the way stuff like this should be handled in 2021. Anything else just causes headaches like this.ssh ali@mac echo $PATH
This is going to echo your local path, not your remote path. Tryssh ali@mac 'echo $PATH'
ls -l
of the cmake link you created.