node-datachannel icon indicating copy to clipboard operation
node-datachannel copied to clipboard

Install fails on AWS Linux 2 on file permissions

Open kare opened this issue 2 years ago • 4 comments

I'm trying to install an application that uses node-datachannel on AWS Linux 2 on Amazon Elastic Beanstalk. Installation fails on the following permission error:

2022/06/21 09:21:25.291718 [INFO] Executing instruction: StageApplication
2022/06/21 09:21:25.291885 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2022/06/21 09:21:25.291901 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2022/06/21 09:21:25.298238 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2022/06/21 09:21:25.298913 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2022/06/21 09:21:25.298931 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2022/06/21 09:21:25.298950 [INFO] The dir .platform/hooks/prebuild/ does not exist
2022/06/21 09:21:25.298954 [INFO] Finished running scripts in /var/app/staging/.platform/hooks/prebuild
2022/06/21 09:21:25.298961 [INFO] Executing instruction: Install customer specified node.js version
2022/06/21 09:21:25.298966 [INFO] installing specified nodejs version...
2022/06/21 09:21:25.299950 [INFO] Running command /bin/sh -c uname -m
2022/06/21 09:21:25.301603 [INFO] x86_64

2022/06/21 09:21:25.301627 [INFO] installing node version 16.13.1
2022/06/21 09:21:25.301658 [INFO] Running command /bin/sh -c uname -m
2022/06/21 09:21:25.303059 [INFO] x86_64

2022/06/21 09:21:25.303074 [INFO] Downloading file with path: /tmp/node-v16.13.1-linux-x64.tar.gz
2022/06/21 09:21:25.303113 [INFO] URL: https://elasticbeanstalk-platform-assets-eu-central-1.s3.eu-central-1.amazonaws.com/stalks/eb_nodejs16_amazon_linux_2_1.0.1559.0_20220519221641/lib/node-v16.13.1-linux-x64.tar.gz
2022/06/21 09:21:25.909100 [INFO] Finished download file from https://elasticbeanstalk-platform-assets-eu-central-1.s3.eu-central-1.amazonaws.com/stalks/eb_nodejs16_amazon_linux_2_1.0.1559.0_20220519221641/lib/node-v16.13.1-linux-x64.tar.gz
2022/06/21 09:21:25.909159 [INFO] extracting /tmp/node-v16.13.1-linux-x64.tar.gz to /opt/elasticbeanstalk/node-install
2022/06/21 09:21:25.909180 [INFO] Running command /bin/sh -c /usr/bin/tar -xzf /tmp/node-v16.13.1-linux-x64.tar.gz -C /opt/elasticbeanstalk/node-install
2022/06/21 09:21:26.683584 [INFO] finished extracting /tmp/node-v16.13.1-linux-x64.tar.gz to /opt/elasticbeanstalk/node-install successfully
2022/06/21 09:21:26.688450 [INFO] create soft link from /opt/elasticbeanstalk/node-install/node-v16.13.1-linux-x64/bin/node to /usr/bin/node
2022/06/21 09:21:26.689093 [INFO] create soft link from /opt/elasticbeanstalk/node-install/node-v16.13.1-linux-x64/bin/corepack to /usr/bin/corepack
2022/06/21 09:21:26.689164 [INFO] create soft link from /opt/elasticbeanstalk/node-install/node-v16.13.1-linux-x64/bin/npx to /usr/bin/npx
2022/06/21 09:21:26.689211 [INFO] create soft link from /opt/elasticbeanstalk/node-install/node-v16.13.1-linux-x64/bin/npm to /usr/bin/npm
2022/06/21 09:21:26.689233 [INFO] Executing instruction: Use NPM to install dependencies
2022/06/21 09:21:26.689247 [INFO] use npm to install dependencies
2022/06/21 09:21:26.689286 [INFO] Running command /bin/sh -c npm config set jobs 1
2022/06/21 09:21:27.047090 [INFO] Running command /bin/sh -c npm --production install
2022/06/21 09:21:53.060518 [INFO] npm notice 
npm notice New minor version of npm available! 8.1.2 -> 8.12.2
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.12.2>
npm notice Run `npm install -g [email protected]` to update!
npm notice 
npm ERR! code 243
npm ERR! path /var/app/staging/node_modules/node-datachannel
npm ERR! command failed
npm ERR! command sh -c prebuild-install || (npm install --ignore-scripts && npm run _prebuild)
npm ERR! prebuild-install WARN install EACCES: permission denied, access '/root/.npm'
npm ERR! glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'scandir',
npm ERR!   path: '/root/.npm/_logs'
npm ERR! }
npm ERR! npm ERR! code EACCES
npm ERR! npm ERR! syscall mkdir
npm ERR! npm ERR! path /root/.npm/_cacache/tmp
npm ERR! npm ERR! errno -13
npm ERR! npm ERR! 
npm ERR! npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! npm ERR! previous versions of npm which has since been addressed.
npm ERR! npm ERR! 
npm ERR! npm ERR! To permanently fix this problem, please run:
npm ERR! npm ERR!   sudo chown -R 900:900 "/root/.npm"

If I run the suggested command sudo chown -R 900:900 "/root/.npm" before installation the installation fails on the same error. AWS EB requires files to be owned by user webapp. After failed npm install some of the files in /root/.npm/_logs directory are owned by root user.

Amazon Graviton arm64 produces the same error.

I suspect that the build process of node-datachannel uses sudo command at some point.

kare avatar Jun 21 '22 09:06 kare

Hi,

We don't use sudo command. This is the install command prebuild-install || (npm install --ignore-scripts && npm run _prebuild)

Are you trying to install the library globally?

murat-dogan avatar Jun 21 '22 12:06 murat-dogan

I'm using node-datachannel as a dependency of streamr-client.

kare avatar Jun 21 '22 12:06 kare

murat@murat-pc:~/js/temp$ node -v
v16.14.2
murat@murat-pc:~/js/temp$ npm i node-datachannel

added 1 package, and audited 60 packages in 4s

7 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

This is what I expect.

murat-dogan avatar Jun 21 '22 12:06 murat-dogan

Everybody talking about adding unsafe-perm=true to file .npmrc. But why is this required?

If you guide me to create a test env on AWS, I can take a look.

murat-dogan avatar Jun 21 '22 13:06 murat-dogan

Hi @kare,

I am closing this for now. If you have further comments, please reopen it.

murat-dogan avatar Oct 06 '22 11:10 murat-dogan