npm install without root permissions (Error while doing npm install as bamboo user)

npm install without root permissions (Error while doing npm install as bamboo user)

Bamboo working directories and source code is owned by 'root' user

Below is the error stack:

bamboo@amapps-03:/disk2/bamboo/xml-data/build-dir/7798786/ML-CFLPLAN8-BDIJOB$ npm install --production
npm WARN deprecated hoek@5.0.4: This version is no longer maintained. Please upgrade to the latest version.
npm WARN checkPermissions Missing write access to /disk2/bamboo/xml-data/build-dir/7798786/ML-CFLPLAN8-BDIJOB
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x6 4"})
npm WARN good@8.1.1 requires a peer of hapi@>=17.x.x but none is installed. You must install peer dependencies yourself.
npm WARN ci-file-listener@2.0.0 No repository field.

npm ERR! path /disk2/bamboo/xml-data/build-dir/7798786/ML-CFLPLAN8-BDIJOB
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/disk2/bamboo/xml-data/build-dir/7798786/ML-CFLPLAN8-BDIJOB'
npm ERR! { Error: EACCES: permission denied, access '/disk2/bamboo/xml-data/build-dir/7798786/ML-CFLPLAN8-BDIJOB'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/disk2/bamboo/xml-data/build-dir/7798786/ML-CFLPLAN8-BDIJOB\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/disk2/bamboo/xml-data/build-dir/7798786/ML-CFLPLAN8-BDIJOB' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/bamboo/.npm/_logs/2019-02-08T23_16_30_752Z-debug.log
bamboo@amapps-03:/disk2/bamboo/xml-data/build-dir/7798786/ML-CFLPLAN8-BDIJOB$

 

 

1 answer

0 votes
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 9, 2019

Hi! 

 

I hope you forget to change ownership for directory to dedicated user e.g. bamboo.

chown -R bamboo:bamboo /disk2/bamboo/

after some actions.

 

Cheers,

Gonchik Tsymzhitov 

Up until here all directories are owned by 'bamboo' user

/disk2/bamboo/xml-data/build-dir

All directories inside this 'build-dir'  directory are owned by root.

Does bamboo creates build working directory as root?, I see all working directories are owned by root user.

 

root@amapps-03:/disk2/bamboo/xml-data# ll
total 56
drwxr-xr-x 5 bamboo bamboo 4096 Jul 16 2018 ./
drwxr-xr-x 4 bamboo bamboo 4096 Mar 13 2018 ../
drwxr-xr-x 2 bamboo bamboo 4096 Jul 16 2018 backups/
drwxr-xr-x 6 bamboo bamboo 4096 Jul 16 2018 build-dir/
drwxr-xr-x 716 bamboo bamboo 36864 Feb 9 03:01 builds/
root@amapps-03:/disk2/bamboo/xml-data# cd build-dir/
root@amapps-03:/disk2/bamboo/xml-data/build-dir# ll
total 40
drwxr-xr-x 6 bamboo bamboo 4096 Jul 16 2018 ./
drwxr-xr-x 5 bamboo bamboo 4096 Jul 16 2018 ../
drwxr-xr-x 88 root root 4096 Oct 10 14:51 196609/
drwxr-xr-x 275 root root 12288 Feb 9 03:01 7798785/
drwxr-xr-x 253 root root 12288 Feb 9 03:01 7798786/
drwxr-xr-x 48 root root 4096 Oct 29 15:16 _git-repositories-cache/
root@amapps-03:/disk2/bamboo/xml-data/build-dir# cd 7798786/
root@amapps-03:/disk2/bamboo/xml-data/build-dir/7798786# ll
total 1040
drwxr-xr-x 253 root root 12288 Feb 9 03:01 ./
drwxr-xr-x 6 bamboo bamboo 4096 Jul 16 2018 ../
drwxr-xr-x 2 root root 4096 Dec 5 15:29 10682369-10780673/
drwxr-xr-x 2 root root 4096 Dec 11 16:15 10682369-10780674/
drwxr-xr-x 2 root root 4096 Jan 3 14:03 10682369-10780675/

By the way my bamboo config is owned by root user

Might that be the reason for having underlying directories owned by root?

-rw-r--r-- 1 root root 2771 Feb 9 23:22 bamboo.cfg.xml

Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 11, 2019

Hi! 

Could you setup as bamboo user and set correct ownership ?

Thanks for the quick response,
config file ownership or the underlying directories of 'build-dir' ?

If I change permissions of the underlying directories of 'build-dir' , won't there be any issues accessing these with bamboo user? because these directories are currently owned by root

Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 11, 2019

Let's check why bamboo run under root, then change ownership

https://confluence.atlassian.com/bamboo/bamboo-remote-agent-installation-guide-289276832.html

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events