[SOLVED] Shell executor fail with error npm: command not found
Summary
I have installed a second gitlab-runner, the same uses "shell executor" for some jobs, I get the following error when trying to use npm:
$ npm install
bash: line 158: npm: command not found
ERROR: Job failed: exit status 1
My first runner which uses "shell executor" as well does not fails with the same job, both configuration are almost identical
I believe I'm using the same OS, config.toml and almost the same npm versions.
Actual behavior
If I send a job I get the error listed above in the "Summary"
However If I manually execute npm in the runner it is working fine with user ubuntu and with user gitlab-runner, see below
ubuntu@:~$ npm install dotenv
npm WARN saveError ENOENT: no such file or directory, open '/home/ubuntu/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/ubuntu/package.json'
npm WARN ubuntu No description
npm WARN ubuntu No repository field.
npm WARN ubuntu No README data
npm WARN ubuntu No license field.
+ dotenv@8.2.0
updated 1 package and audited 1 package in 0.414s
found 0 vulnerabilities
gitlab-runner@:~$ npm install dotenv
npm WARN saveError ENOENT: no such file or directory, open '/home/gitlab-runner/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/gitlab-runner/package.json'
npm WARN gitlab-runner No description
npm WARN gitlab-runner No repository field.
npm WARN gitlab-runner No README data
npm WARN gitlab-runner No license field.
+ dotenv@8.2.0
updated 1 package and audited 1 package in 0.412s
found 0 vulnerabilities
Expected behavior
I expect that this new runner installation with shell executor is able to handle npm install, as my other runner with almost identical configuration is handling npm shell jobs without this problem.
Relevant logs and/or screenshots
Active process As below, I see no diferrences with my working runner.
ubuntu@:~$ ps aux | grep gitlab-runner
root 1010 1.7 0.1 46864 28404 ? Ssl Jul13 0:46 /usr/lib/gitlab-runner/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner
Journalctl log below just displays WARNING: Job failed: exit status 1
job log
Jul 13 23:42:47 ip-+++++++ gitlab-runner[1010]: WARNING: Job failed: exit status 1 duration=5.365055472s job=+++++++++++ project=+++++ runner=+++++++
Jul 13 23:42:47 ip-+++++++ systemd-logind[1014]: Removed session c14.
Jul 13 23:42:47 ip-+++++++ gitlab-runner[1010]: WARNING: Job failed: exit status 1 duration=5.365055472s job=+++++++ project=+++++++ runner=+++++++
Jul 13 23:42:47 ip-+++++++ gitlab-runner[1010]: WARNING: Failed to process runner builds=0 error=exit status 1 executor=shell runner=+++++++
Jul 13 23:42:47 ip-+++++++ gitlab-runner[1010]: WARNING: Failed to process runner builds=0 error=exit status 1 executor=shell runner=+++++++
Environment description
PATH
ubuntu@:~$ echo $PATH
/home/ubuntu/.nvm/versions/node/v12.18.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
gitlab-runner@:~$ echo $PATH
/home/gitlab-runner/.nvm/versions/node/v12.18.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
OS
ubuntu@:~$ uname -a
Linux ip-xxxxxx 5.3.0-1030-aws #32~18.04.1-Ubuntu SMP Tue Jun 30 23:04:16 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@:~$ cat /etc/os*
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
ubuntu@:~$ nvm --version
0.35.2
ubuntu@:~$ node -v
v12.18.2
ubuntu@:~$ npm -v
6.14.5
apt show gitlab-runner
Package: gitlab-runner
Version: 13.1.1
Priority: optional
Section: admin
Maintainer: GitLab Inc. <support@gitlab.com>
Installed-Size: 75.9 MB
Provides: gitlab-ci-multi-runner
Depends: git, curl, tar, ca-certificates
Suggests: docker-engine
Conflicts: gitlab-runner-beta, gitlab-ci-multi-runner, gitlab-ci-multi-runner-beta
Replaces: gitlab-ci-multi-runner
Homepage: https://gitlab.com/gitlab-org/gitlab-runner
Download-Size: 51.2 MB
APT-Sources: https://packages.gitlab.com/runner/gitlab-runner/ubuntu bionic/main amd64 Packages
Description: GitLab Runner
config.toml contents
[[runners]]
name = "gitlab-runner-xxxxxxx"
limit = 2
url = "https://xxxxxxxxx.com/"
token = "xxxxxxxxxxxxxxxxx"
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
Used GitLab Runner version
gitlab-runner --version
Version: 12.4.1
Git revision: 05161b14
Git branch: 12-4-stable
GO version: go1.10.8
Built: 2019-10-28T12:49:57+0000
OS/Arch: linux/amd64