我正在尝试在远程服务器上运行 bash 脚本以通过 rbenv 安装 ruby。
#!/bin/bash
# ssh [email protected] 'bash -s' < configure.sh
echo "ruby 3.2.1"
rbenv install 3.2.1 --verbose
rbenv global 3.2.1
在远程服务器上rbenv
已经为用户安装了deploy
。如果我登录到该服务器,它运行正常。
❯ ssh [email protected]
deploy@ubuntu-focal:~$ rbenv
rbenv 1.2.0-59-g0704e65
Usage: rbenv <command> [<args>...]
但是如果我们尝试通过 ssh 运行命令,它就找不到了。
❯ ssh [email protected] "rbenv"
bash: rbenv: command not found
脚本也有同样的问题。
❯ ssh [email protected] 'bash -s' < configure.sh
ruby 3.2.1
bash: line 5: rbenv: command not found
bash: line 6: rbenv: command not found
bash: line 7: ruby: command not found
bash: line 9: gem: command not found
bash: line 10: gem: command not found