简体   繁体   English

尽管git在用户路径中,但“未安装ENOGIT git或PATH中未安装git”

[英]“ENOGIT git is not installed or not in the PATH” although git is in the user's path

I'm setting up a TeamCity build project, in which I want to assemble a javascript web app, using a powershell script with the following contents: 我正在设置一个TeamCity构建项目,在其中要使用具有以下内容的powershell脚本来组装javascript网络应用程序:

npm install
bower install
grunt build

When TeamCity runs the script, I get an error 当TeamCity运行脚本时,出现错误

bower jquery-stopwatch#f1bdae95ace634169b50c4a2565116389668edc9
    ENOGIT git is not installed or not in the PATH

although if I log on to the build agent via RDP (using the same user account as the build agent service runs under) and run those command from a PS instance, everything works as expected (bower installs some fifteen more components before the script continues). 尽管如果我通过RDP登录到构建代理(使用与运行构建代理服务所使用的用户帐户相同)并从PS实例运行那些命令,一切都会按预期进行(在脚本继续执行之前,安装了15个以上的组件) 。

Since the first step ( npm install ) takes a few minutes each time, trouble-shooting this through trial-and-error with the TeamCity build is very slow and tedious, but I haven't so far found any other way to reproduce. 由于第一步( npm install )每次需要花费几分钟,因此通过TeamCity构建的反复试验来解决此问题非常缓慢且乏味,但是到目前为止,我还没有找到其他可重现的方法。

What else should I try? 我还应该尝试什么? What could be the culprit? 可能是罪魁祸首?

This is commonly caused by installing the tools (and therefore changing the PATH variable) after starting the service/program. 这通常是由于在启动服务/程序之后安装工具(因此更改了PATH变量)引起的。 The environment is initialized on startup, and not reloaded by external changes to the variables. 该环境在启动时初始化,并且不会通过对变量的外部更改来重新加载。

So, as they say, have you tried turning it off and on again? 因此,正如他们所说,您是否尝试过将其关闭然后再次打开? :) :)

The solution is to run your command in Git Shell tool which identify the Git path on your machine. 解决方案是在Git Shell工具中运行命令,该工具可识别计算机上的Git路径。 Install any of the Git UI tools based on your current OS: 根据您当前的操作系统安装任何Git UI工具:

Download Git UI tools: 下载Git UI工具:

https://git-scm.com/download/gui/win https://git-scm.com/download/gui/win

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

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