linux - 找不到 SSH Shell 命令(composer、npm)
问题描述
我的服务器是带有 whm 和 cpanel 的 a2hosting 上的 linux 经销商计划。
我的项目是 PHP Laravel。
项目构建,然后使用Copy Files Over SSH
任务我能够将文件复制到我的服务器。
问题是当我尝试在此之后添加任务SSH
时出现错误。它使用与文件复制任务相同的 SSH 连接和密钥。喜欢和工作的事情。composer install
npm install
cd
ls
当我在本地使用相同的用户名和相同的私钥并运行composer install
它时,以及npm install
. 运行 composer 和 npm 后,站点加载正常,但我希望它是自动化的,所以我不必手动运行这些命令。
这是我的inline script
:
composer install
我的错误如下所示:
2019-03-11T16:34:21.4468896Z ##[section]Starting: Run Composer
2019-03-11T16:34:21.4471875Z ==============================================================================
2019-03-11T16:34:21.4472119Z Task : SSH
2019-03-11T16:34:21.4472240Z Description : Run shell commands or a script on a remote machine using SSH
2019-03-11T16:34:21.4472332Z Version : 0.148.0
2019-03-11T16:34:21.4472433Z Author : Microsoft Corporation
2019-03-11T16:34:21.4472519Z Help : [More Information](http://go.microsoft.com/fwlink/?LinkId=821892)
2019-03-11T16:34:21.4472635Z ==============================================================================
2019-03-11T16:34:21.8985848Z composer install
2019-03-11T16:34:21.9008544Z Trying to establish an SSH connection to ***@mydomain.com:7822
2019-03-11T16:34:21.9181145Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9181767Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9182133Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9182449Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9183364Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9183731Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9184084Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9184417Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9184742Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9185068Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9185405Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9185751Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9186053Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:22.2806417Z Successfully connected.
2019-03-11T16:34:23.0424509Z tr -d '\015' <"./sshscript_1552322" > "./sshscript_1552322._unix"
2019-03-11T16:34:23.1378047Z chmod +x "./sshscript_1552322._unix"
2019-03-11T16:34:23.2240403Z "./sshscript_1552322._unix"
2019-03-11T16:34:23.3118392Z
2019-03-11T16:34:23.3171367Z ##[error]./sshscript_1552322._unix: line 3: composer: command not found
2019-03-11T16:34:23.3180458Z
2019-03-11T16:34:23.3181101Z ##[error]Command failed with errors on remote machine.
2019-03-11T16:34:23.4532093Z ##[section]Finishing: Run Composer
解决方案
因为您可以在通过 SSH 手动登录时执行命令,但不能通过 Azure 脚本执行相同的命令。这可能意味着您的管道脚本无法加载~/.bashrc
或无法加载预期$PATH
值以便能够找到composer
命令。您需要通过手动运行和通过管道脚本来确保您的管道脚本包含正确的$PATH
值echo $PATH
,然后比较该值,或者您可以尝试放置composer
二进制文件的完整路径,您可以通过执行手动获取它which composer
,同样适用npm
.
更新: 正如您提到的 $PATH 有问题,您可以在使用的 bash 脚本中手动定义它,如下所示:
export PATH=/my/missing/path:$PATH
推荐阅读
- c++ - C++如何为头文件创建搜索路径
- apache-spark - AnalysisException: u'无法解析列名
- excel - 使用VBScript在后台打开Excel工作簿时,如何同时打开另一个工作簿?
- mysql - 当我尝试在命令行中访问 Mysql 时,我在命令行中收到错误消息
- reactjs - 如何在两个不同的组件中使用一个状态?
- python - 在 VS Code 中由 Jupyter Notebook 调用时在包中的函数中触发调试会话
- swift - 如何转换 snapshotView 对象?
- pagination - Xero API - 如何在分页中指定页面大小
- flutter - VSCODE 调试和新项目的问题
- swift - 如何停止在表格视图中重复单元格?