[英]SSH Shell commands not found (composer, npm)
我的服務器是使用whm和cpanel在a2hosting上的Linux經銷商計划。
我的項目是PHP Laravel。
該項目將生成,然后使用Copy Files Over SSH
任務Copy Files Over SSH
復制到服務器。
問題是,當我嘗試在composer install
和npm install
之后添加SSH
任務時,出現錯誤。 它使用與文件復制任務相同的SSH連接和密鑰。 諸如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
命令。 您需要通過手動運行echo $PATH
並通過管道腳本來確保管道腳本包含正確的$PATH
值,然后比較該值,或者您可以嘗試放置composer
二進制文件的完整路徑,可以通過以下方式手動獲取它:執行which composer
, npm
。
更新:正如您提到的那樣,$ PATH存在問題,您可以在正在使用的bash腳本中手動定義它,如下所示:
export PATH=/my/missing/path:$PATH
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.