简体   繁体   English

Bower-使用Symfony Process在PATH中未安装或未安装ENOGIT git

[英]Bower - ENOGIT git is not installed or not in the PATH using Symfony Process

We are currently running into an issue where runnning bower update --allow-root via Symfony's Process component which results in an error or; 当前,我们遇到了一个问题,即通过Symfony的Process组件运行bower update --allow-root会导致错误或;

bower jquery#* <3.0 * * * * * * * * ENOGIT git is not installed or not in the PATH

Running git or bower via the component retrieves expected response. 通过组件运行gitbower检索预期的响应。

It seems as if bower/node cant find the git path. 看来Bower / Node无法找到git路径。 Running the follwoing via Symphony Process 通过Symphony Process进行跟踪

echo $PATH

results in 结果是

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

inside /usr/bin is; /usr/bin里面是;

lrwxrwxrwx 1 root   root          35 Feb 21 09:06 bower -> ../lib/node_modules/bower/bin/bower
lrwxrwxrwx 1 root   root          22 Jan 23 11:49 node -> /etc/alternatives/node
-rwxr-xr-x 1 root   root          25163808 Jan  6 00:12 nodejs
lrwxrwxrwx 1 root   root          38 Jan  6 00:11 npm -> ../lib/node_modules/npm/bin/npm-cli.js
-rwxr-xr-x 1 root   root          1862800 Mar 23  2016 git

Running which git via Symfony Process returns /usr/bin/git 通过Symfony Process运行which git返回/usr/bin/git

Running which bower via Symfony Process returns /usr/bin/bower 通过Symfony Process运行which bower返回/usr/bin/bower

Running which node via Symfony Process returns /usr/bin/node 通过Symfony Process运行which node将返回/usr/bin/node

Stack Trace: 堆栈跟踪:

Error: git is not installed or not in the PATH
    at createError (/usr/lib/node_modules/bower/lib/util/createError.js:4:15)
    at GitHubResolver.GitResolver (/usr/lib/node_modules/bower/lib/core/resolvers/GitResolver.js:45:15)
    at GitHubResolver.GitRemoteResolver (/usr/lib/node_modules/bower/lib/core/resolvers/GitRemoteResolver.js:10:17)
    at new GitHubResolver (/usr/lib/node_modules/bower/lib/core/resolvers/GitHubResolver.js:13:23)
    at /usr/lib/node_modules/bower/lib/core/resolverFactory.js:18:16
From previous event:
    at PackageRepository.fetch (/usr/lib/node_modules/bower/lib/core/PackageRepository.js:46:6)
    at Manager._fetch (/usr/lib/node_modules/bower/lib/core/Manager.js:323:51)
    at Array.forEach (native)
    at Manager.resolve (/usr/lib/node_modules/bower/lib/core/Manager.js:116:23)
    at Project._bootstrap (/usr/lib/node_modules/bower/lib/core/Project.js:559:6)
    at /usr/lib/node_modules/bower/lib/core/Project.js:193:21

Console trace:
Error
    at StandardRenderer.error (/usr/lib/node_modules/bower/lib/renderers/StandardRenderer.js:81:37)
    at Logger.<anonymous> (/usr/lib/node_modules/bower/lib/bin/bower.js:110:26)
    at emitOne (events.js:96:13)
    at Logger.emit (events.js:188:7)
    at Logger.emit (/usr/lib/node_modules/bower/lib/node_modules/bower-logger/lib/Logger.js:29:39)
    at /usr/lib/node_modules/bower/lib/commands/index.js:48:20
    at _rejected (/usr/lib/node_modules/bower/lib/node_modules/q/q.js:844:24)
    at /usr/lib/node_modules/bower/lib/node_modules/q/q.js:870:30
    at Promise.when (/usr/lib/node_modules/bower/lib/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/usr/lib/node_modules/bower/lib/node_modules/q/q.js:788:41)

Server: 服务器:

NGINX 
1 GB  
30 GB Disk 
Ubuntu 16.04.1 x64
Linux 4.4.0-62-generic x64

has anyone else ran into this problem or could suggest more tests to debug. 有没有其他人遇到这个问题,或者可以建议更多测试进行调试。

regards 问候

EDIT 编辑

Ive debugged it back to /usr/lib/node_modules/bower/lib/util/createError.js 我已经将其调试回/usr/lib/node_modules/bower/lib/util/createError.js

var which = require('which');
var hasGit;

// Check if git is installed
try {
    which.sync('git');
    hasGit = true;
} catch (ex) {
    hasGit = false;
}

EDIT 2 编辑2

tracked it down to a node module which ; 跟踪它到一个节点模块which ;

https://github.com/npm/node-which/blob/master/which.js#L21 https://github.com/npm/node-which/blob/master/which.js#L21

which the line process.env.PATH is returning undefined . 这行process.env.PATH返回undefined

export PATH=$PATH:/usr/bin; bower update

process.env.PATH was returning undefined from the which node module; process.env.PATHwhich节点模块返回undefined

https://github.com/npm/node-which/blob/master/which.js#L21 https://github.com/npm/node-which/blob/master/which.js#L21

Adding the PATH prefix to the command fixed this issue. 在命令中添加PATH前缀可解决此问题。

Being more specific to my issue, Symfony's Process class takes a third parameter for environment variables; 针对我的问题,Symfony的Process类采用了第三个参数作为环境变量。

$process = new Process( 'php composer.phar update', $path, [ 'PATH' => '/usr/bin', 'HOME' => '/home/forge' ] );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM