0

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.

5
  • First, MacBook Pro M1 is hardware. The OS version is more important. I assume macOS BigSur (11.2)? “I have installed CMake on my MacBookPro m1 and have made symbolic link…” Did you compile it from source by hand? Don’t do that. Nowadays you should just use Homebrew. Install Homebrew and then run brew install cmake. That is the way stuff like this should be handled in 2021. Anything else just causes headaches like this. Mar 26, 2021 at 4:12
  • 3
    ssh ali@mac echo $PATH This is going to echo your local path, not your remote path. Try ssh ali@mac 'echo $PATH'
    – Kenster
    Mar 26, 2021 at 11:41
  • let's see an ls -l of the cmake link you created. Mar 26, 2021 at 14:32
  • @Kenster you should post this as an answer...
    – agtoever
    Mar 27, 2021 at 7:01
  • Does this answer your question? Set PATH when SSH into MacOS Mar 27, 2021 at 16:15

1 Answer 1

0

Thanks to Kenster's comment, I learned I was getting $PATH from my local machine with ssh ali@mac echo $PATH, running ssh ali@mac 'echo $PATH' shows that /usr/local/bin is not part of the path. This answers my misunderstanding above.

I was able to fix the problem by Setting PATH for Mac ssh.

Thanks everyone for valuable feed-backs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .