angular-cli
angular-cli copied to clipboard
git: not found
Sorry if this is the wrong place to post this (docker rookie here) but I'm trying to get the git last commit hash using this script
const revision = new Observable<string>(s => {
exec('git rev-parse --short HEAD',
function (error: Error, stdout: Buffer, stderr: Buffer) {
if (error !== null) {
console.log('git error: ' + error + stderr);
}
s.next(stdout.toString().trim());
s.complete();
});
});
works fine locally but when using this docker we get
git error: Error: Command failed: git rev-parse --short HEAD
/bin/sh: git: not found
/bin/sh: git: not found
Any hint on how I can move forward?
I think your git command is not in /bin/sh. You can locate it with:
$ which git
/usr/bin/git
So you have two options:
- Add
/usr/bin/to your$PATH - Change your code:
exec('/usr/bin/git rev-parse --short HEAD'...
Hope this can be helpful.
Regards, Alex
Hmm.. perhaps the docker image needs to have "apk add git" for this to work?
Of course! if it's a docker image, you should install git