Bower - 使用Symfony进程

时间:2017-02-21 10:45:02

标签: node.js git symfony bower

我们目前遇到的问题是通过Symfony的Process组件运行bower update --allow-root导致错误或者

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

通过组件运行gitbower将检索预期的响应。

似乎bower / node无法找到git路径。通过Symphony Process运行以下内容

echo $PATH

结果

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

/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

通过Symfony Process运行which git会返回/usr/bin/git

通过Symfony Process运行which bower会返回/usr/bin/bower

通过Symfony Process运行which node会返回/usr/bin/node

堆栈追踪:

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)

服务器:

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

有其他人遇到过这个问题或者可能会建议更多的测试来调试。

问候

修改

我已将其调回/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;
}

编辑2

将其跟踪到节点模块which;

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

行[{1}}正在返回process.env.PATH

0 个答案:

没有答案