Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission Denied error when attempting install on AWS Elastic Beanstalk #50

Closed
bengrunfeld opened this issue Feb 8, 2019 · 3 comments

Comments

@bengrunfeld
Copy link

Getting permission denied error when attempting to install tulind: ^0.8.14 on AWS Elastic Beanstalk (EB).

System information:

Linux ip-172-31-30-251 4.14.88-72.76.amzn1.x86_64 #1 SMP Mon Jan 7 19:47:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Errors:

[2019-02-08T04:42:22.707Z] INFO  [3171]  - [Application deployment app-6a8c-190208_153950@1/StartupStage0/AppDeployPreHook/50npm.sh] : Activity execution failed, because: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
  
  > @tensorflow/tfjs-node@0.1.21 install /tmp/deployment/application/node_modules/@tensorflow/tfjs-node
  > node scripts/install.js
  
  (node:3389) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, rmdir '/tmp/deployment/application/node_modules/@tensorflow/tfjs-node/deps'
  (node:3389) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  (node:3389) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  
  > tulind@0.8.14 install /tmp/deployment/application/node_modules/tulind
  > node-pre-gyp install --fallback-to-build
  
  node-pre-gyp WARN Using request for node-pre-gyp https download 
  node-pre-gyp WARN Pre-built binaries not installable for tulind@0.8.14 and node@10.15.0 (node-v64 ABI, glibc) (falling back to source compile with node-gyp) 
  node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/tulind/lib' 
  gyp ERR! configure error 
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/tulind/build'
  gyp ERR! System Linux 4.14.88-72.76.amzn1.x86_64
  gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64/tulind.node" "--module_name=tulind" "--module_path=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
  gyp ERR! cwd /tmp/deployment/application/node_modules/tulind
  gyp ERR! node -v v10.15.0
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! not ok 
  node-pre-gyp ERR! build error 
  node-pre-gyp ERR! stack Error: Failed to execute '/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64/tulind.node --module_name=tulind --module_path=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
  node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/tmp/deployment/application/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
  node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
  node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
  node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
  node-pre-gyp ERR! System Linux 4.14.88-72.76.amzn1.x86_64
  node-pre-gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/node" "/tmp/deployment/application/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
  node-pre-gyp ERR! cwd /tmp/deployment/application/node_modules/tulind
  node-pre-gyp ERR! node -v v10.15.0
  node-pre-gyp ERR! node-pre-gyp -v v0.12.0
  node-pre-gyp ERR! not ok 
  Failed to execute '/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64/tulind.node --module_name=tulind --module_path=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! tulind@0.8.14 install: `node-pre-gyp install --fallback-to-build`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the tulind@0.8.14 install script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /tmp/.npm/_logs/2019-02-08T04_42_22_671Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/npm
  Setting npm config jobs to 1
  npm config jobs set to 1
  Running npm with --production flag
  Failed to run npm install. Snapshot logs for more details.
  UTC 2019/02/08 04:42:22 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log 
  
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
      main()
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
      node_version_manager.run_npm_install(options.app_path)
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
      self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
      raise e
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (ElasticBeanstalk::ExternalInvocationError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
  
  > @tensorflow/tfjs-node@0.1.21 install /tmp/deployment/application/node_modules/@tensorflow/tfjs-node
  > node scripts/install.js
  
  (node:3389) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, rmdir '/tmp/deployment/application/node_modules/@tensorflow/tfjs-node/deps'
  (node:3389) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  (node:3389) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  
  > tulind@0.8.14 install /tmp/deployment/application/node_modules/tulind
  > node-pre-gyp install --fallback-to-build
  
  node-pre-gyp WARN Using request for node-pre-gyp https download 
  node-pre-gyp WARN Pre-built binaries not installable for tulind@0.8.14 and node@10.15.0 (node-v64 ABI, glibc) (falling back to source compile with node-gyp) 
  node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/tulind/lib' 
  gyp ERR! configure error 
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/tulind/build'
  gyp ERR! System Linux 4.14.88-72.76.amzn1.x86_64
  gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64/tulind.node" "--module_name=tulind" "--module_path=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
  gyp ERR! cwd /tmp/deployment/application/node_modules/tulind
  gyp ERR! node -v v10.15.0
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! not ok 
  node-pre-gyp ERR! build error 
  node-pre-gyp ERR! stack Error: Failed to execute '/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64/tulind.node --module_name=tulind --module_path=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
  node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/tmp/deployment/application/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
  node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
  node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
  node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
  node-pre-gyp ERR! System Linux 4.14.88-72.76.amzn1.x86_64
  node-pre-gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/node" "/tmp/deployment/application/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
  node-pre-gyp ERR! cwd /tmp/deployment/application/node_modules/tulind
  node-pre-gyp ERR! node -v v10.15.0
  node-pre-gyp ERR! node-pre-gyp -v v0.12.0
  node-pre-gyp ERR! not ok 
  Failed to execute '/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64/tulind.node --module_name=tulind --module_path=/tmp/deployment/application/node_modules/tulind/lib/binding/Release/node-v64-linux-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! tulind@0.8.14 install: `node-pre-gyp install --fallback-to-build`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the tulind@0.8.14 install script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /tmp/.npm/_logs/2019-02-08T04_42_22_671Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/npm
  Setting npm config jobs to 1
  npm config jobs set to 1
  Running npm with --production flag
  Failed to run npm install. Snapshot logs for more details.
  UTC 2019/02/08 04:42:22 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log 
  
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
      main()
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
      node_version_manager.run_npm_install(options.app_path)
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
      self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
      raise e
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v10.15.0-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)
@bengrunfeld
Copy link
Author

bengrunfeld commented Feb 8, 2019

So, I found the solution with some creative Googling. Needed to use two steps to get it to work but it solved the issue.

Step 1

link to source
Place this code into .ebextensions/00_change_npm_permissions.config

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/00_set_tmp_permissions.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      chown -R nodejs:nodejs /tmp/.npm

Step 2

link to source
Place this code into .npmrc:

# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5
unsafe-perm=true

@tina1998612
Copy link

So, I found the solution with some creative Googling. Needed to use two steps to get it to work but it solved the issue.

Step 1

link to source
Place this code into .ebextensions/00_change_npm_permissions.config

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/00_set_tmp_permissions.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      chown -R nodejs:nodejs /tmp/.npm

Step 2

link to source
Place this code into .npmrc:

# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5
unsafe-perm=true

Thanks!! This is the only solution I found that works for me. :)

@pgoldweic
Copy link

So, I found the solution with some creative Googling. Needed to use two steps to get it to work but it solved the issue.

Step 1

link to source Place this code into .ebextensions/00_change_npm_permissions.config

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/00_set_tmp_permissions.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      chown -R nodejs:nodejs /tmp/.npm

Step 2

link to source Place this code into .npmrc:

# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5
unsafe-perm=true

Thanks @bengrunfeld for that solution. However, how would you modify it to run under Amazon Linux 2? (newest Elastic Beanstalk platform, after deprecation of old in December 2020).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants