问题
I have cloned a git repository it's an Angular 7 ASP.NET app, everything is fine in the project but when I try to restore npm packages I get the error below.
\Microsoft\TeamFoundation\Team Explorer\Git\cmd\git.EXE submodule update - q --init --recursive fatal: 'submodule' appears to be a git command, but we were not able to execute it. Maybe git-submodule is broken? at ChildProcess.exithandler (child_process.js:291:12) at ChildProcess.emit (events.js:182:13) at maybeClose (internal/child_process.js:961:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5) npm ERR! cb() never called!
Package.json
{
"name": "name",
"version": "6.1.1",
"license": "......",
"scripts": {
"ng": "ng",
"start": "ng serve --open",
"start-hmr": "ng serve --configuration hmr -sm=false",
"start-hmr-sourcemaps": "ng serve --hmr -e=hmr",
"build": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev",
"build-stats": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev --stats-json",
"build-prod": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod",
"build-prod-stats": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod --stats-json",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"bundle-report": "webpack-bundle-analyzer dist/stats.json"
},
"private": true,
"dependencies": {
"@agm/core": "1.0.0-beta.3",
"@angular/animations": "6.0.5",
"@angular/cdk": "6.2.1",
"@angular/common": "6.0.5",
"@angular/compiler": "6.0.5",
"@angular/core": "6.0.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.6.8",
"@angular/cli": "6.0.8",
"@angular/compiler-cli": "6.0.5",
"@angular/language-service": "6.0.5",
"@angularclass/hmr": "2.1.3",
"typescript": "2.7.2",
"webpack-bundle-analyzer": "2.13.1"
}
}
My installed node-version
is 10.7.0
and npm-version
is 6.4.1
I found on GitHub some issues like this and they added a fix in npm-lifecycle, so I installed the npm-lifecycle
but I'm still getting the same error
回答1:
The submodule
command is not built into the base git.exe
binary, it is implemented as a shell script named git-submodule
, which needs to be accessible from the %PATH%
, and to be executable for the user who runs the action.
- What is your
%PATH%
(or the%PATH%
for your npm process) ? - Does it include the path to your git installation, which seems to be somewhere in
\Microsoft\TeamFoundation\Team Explorer\Git\
? - Does the user which runs the npm process have execution rights on
git-submodule
?
回答2:
Git 2.24 (Q4 2019) will fix a possible cause for this error message, seen on Windows.
See commit 4e1a641 (24 Aug 2019) by Adam Roben (aroben).
(Merged by Junio C Hamano -- gitster -- in commit 6f21347, 30 Sep 2019)
mingw
: fix launching of externals from Unicode pathsIf Git were installed in a path containing non-ASCII characters, commands such as
git am
andgit submodule
, which are implemented as externals, would fail to launch with the following error:fatal: 'am' appears to be a git command, but we were not able to execute it. Maybe git-am is broken?
This was due to
lookup_prog
not being Unicode-aware. It was somehow missed in 85faec9 (Win32: Unicode file name support (exceptdirent
), 2012-03-15, Git v2.1.0-rc0).Note that the only problem in this function was calling
GetFileAttributes()
instead ofGetFileAttributesW()
.
The calls toaccess()
were fine becauseaccess()
is a macro which resolves tomingw_access()
, which already handles Unicode correctly.
Butlookup_prog()
was changed to use_waccess()
directly so that we only convert the path to UTF-16 once.To make things work correctly, we have to maintain UTF-8 and UTF-16 versions in tandem in
lookup_prog()
.
回答3:
Probably you don't have Git for windows installed. What I did, and it seems to have worked for me, is to open the visual studio installer, then choose to "modify" the current installation and from "Individual Components" tab I checked "Git for Windows" (which was not checked).
After the installation I did not get the same error again.
来源:https://stackoverflow.com/questions/54672008/submodule-appears-to-be-a-git-command-but-we-were-not-able-to-execute-it