npm ERR! code ENOGIT
Summary
Can't run npm install
in gitlab ci because git is not on the PATH
Steps to reproduce
I have no idea how to reliably reproduce this. My team has several repos for the same project. I'm using the exact same gitlab CI for two different repos (found below). In one repo, the CI runs fine. In another repo, the CI fails with error in the title of this issue.
What is the current bug behavior?
gitlab-runner exec docker test
results in npm ERR! code ENOGIT
What is the expected correct behavior?
test pipeline should succeed
Relevant logs and/or screenshots
Here's my .gitlab-ci.yml
image: "node:4-alpine"
stages:
- test
test:
stage: test
script:
- npm install -g npm@latest
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
# we can't cache effectively here: https://gitlab.com/gitlab-org/gitlab-ce/issues/35862
- npm install
- npm test
Here's the local output in the failing repo:
9:09AM /Users/paymahn/solvvy/ticket-processor gitlab-ci ✱ ◼
❮❮❮ gitlab-runner exec docker test
WARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of upcoming releases
WARNING: You most probably have uncommitted changes.
WARNING: These changes will not be tested.
Running with gitlab-runner 10.4.0 (857480b6)
on ()
Using Docker executor with image node:4-alpine ...
Using docker image sha256:48de35adabce6b3d466ec13ec3b3ee48f9604e62a169028fd2ccebd8b3aae807 for predefined container...
Pulling docker image node:4-alpine ...
Using docker image node:4-alpine ID=sha256:14fa596bb048729ffdfadf2be96907a08fe1ec857fbd351b769cf912f3acc9a2 for build container...
Running on runner--project-0-concurrent-0 via PaymahnSolvvy.local...
Cloning repository...
Cloning into '/builds/project-0'...
done.
Checking out 04fc50bc as gitlab-ci...
Skipping Git submodules setup
$ npm install -g npm@latest
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
npm@5.6.0 /usr/local/lib/node_modules/npm
$ echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
$ npm install
npm ERR! code ENOGIT
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-02-20T17_09_35_688Z-debug.log
Running after script...
ERROR: Job failed: exit code 1
FATAL: exit code 1
Here's the output in the succeeding repo (note that it fails because the token is non-existant but npm install is succeeding):
9:12AM /Users/paymahn/solvvy/node-sauron ✘ 1 gitlab-ci
❮❮❮ gitlab-runner exec docker test
WARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of upcoming releases
WARNING: You most probably have uncommitted changes.
WARNING: These changes will not be tested.
Running with gitlab-runner 10.4.0 (857480b6)
on ()
Using Docker executor with image node:4-alpine ...
Using docker image sha256:48de35adabce6b3d466ec13ec3b3ee48f9604e62a169028fd2ccebd8b3aae807 for predefined container...
Pulling docker image node:4-alpine ...
Using docker image node:4-alpine ID=sha256:14fa596bb048729ffdfadf2be96907a08fe1ec857fbd351b769cf912f3acc9a2 for build container...
Running on runner--project-0-concurrent-0 via PaymahnSolvvy.local...
Cloning repository...
Cloning into '/builds/project-0'...
done.
Checking out 261ac8d6 as gitlab-ci...
Skipping Git submodules setup
$ echo `which git`
$ npm install -g npm@latest
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
npm@5.6.0 /usr/local/lib/node_modules/npm
$ echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
$ npm install
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated formatio@1.1.1: This package is unmaintained. Use @sinonjs/formatio instead
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated to-iso-string@0.0.2: to-iso-string has been deprecated, use @segment/to-iso-string instead.
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated nomnom@2.0.0: Package no longer supported. Contact support@npmjs.com for more info.
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm ERR! code E404
npm ERR! 404 Not Found: @solvvy/mq@^0.2.1
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-02-20T17_12_49_558Z-debug.log
Running after script...
ERROR: Job failed: exit code 1
FATAL: exit code 1
Note the output of echo 'which git'
which is empty. In the succeeding repo, git doesn't seem to be on the PATH but there aren't any complaints.
Results of GitLab environment info
❮❮❮ gitlab-runner --version
Version: 10.4.0
Git revision: 857480b6
Git branch: 10-4-stable
GO version: go1.9.2
Built: Mon, 22 Jan 2018 11:33:26 +0000
OS/Arch: darwin/amd64