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

npm run deploy ends up in Error (claudia create) on Linux #125

Open
mhuebner opened this issue Mar 21, 2017 · 5 comments
Open

npm run deploy ends up in Error (claudia create) on Linux #125

mhuebner opened this issue Mar 21, 2017 · 5 comments

Comments

@mhuebner
Copy link

mhuebner commented Mar 21, 2017

My build is based on node 4.3.2 and npm 2.14.12. AWS cli is setup and configured.

npm run test-config runs fine:

Configuration check finished.

Your configuration is green!
npm info lifecycle [email protected]~posttest-config: [email protected]
npm info ok

npm run deploy throws the following error:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle [email protected]~predeploy: [email protected]
6 silly lifecycle [email protected]~predeploy: no script for predeploy, continuing
7 info lifecycle [email protected]~deploy: [email protected]
8 verbose lifecycle [email protected]~deploy: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~deploy: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/root/aws-lambda-image/node_modules/.bin:/root/.local/bin:/root/.local/bin:/root/.local/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle [email protected]~deploy: CWD: /root/aws-lambda-image
11 silly lifecycle [email protected]~deploy: Args: [ '-c',
11 silly lifecycle   'claudia create --profile $npm_package_config_profile --region $npm_package_config_region --version dev --handler index.handler --no-optional-dependencies --timeout $npm_package_config_timeout --memory $npm_package_config_memory --policies policies/*.json' ]
12 silly lifecycle [email protected]~deploy: Returned: code: 1  signal: null
13 info lifecycle [email protected]~deploy: Failed to exec deploy script
14 verbose stack Error: [email protected] deploy: `claudia create --profile $npm_package_config_profile --region $npm_package_config_region --version dev --handler index.handler --no-optional-dependencies --timeout $npm_package_config_timeout --memory $npm_package_config_memory --policies policies/*.json`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:194:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:194:7)
14 verbose stack     at maybeClose (internal/child_process.js:899:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd /root/aws-lambda-image
17 error Linux 4.9.12-moby
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
19 error node v7.7.3
20 error npm  v4.1.2
21 error code ELIFECYCLE
22 error [email protected] deploy: `claudia create --profile $npm_package_config_profile --region $npm_package_config_region --version dev --handler index.handler --no-optional-dependencies --timeout $npm_package_config_timeout --memory $npm_package_config_memory --policies policies/*.json`
22 error Exit status 1
23 error Failed at the [email protected] deploy script 'claudia create --profile $npm_package_config_profile --region $npm_package_config_region --version dev --handler index.handler --no-optional-dependencies --timeout $npm_package_config_timeout --memory $npm_package_config_memory --policies policies/*.json'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the aws-lambda-image package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     claudia create --profile $npm_package_config_profile --region $npm_package_config_region --version dev --handler index.handler --no-optional-dependencies --timeout $npm_package_config_timeout --memory $npm_package_config_memory --policies policies/*.json
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs aws-lambda-image
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls aws-lambda-image
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
@mhuebner
Copy link
Author

mhuebner commented Mar 22, 2017

Sometimes I get the following error output:

Source directory is the Node temp directory. Cowardly refusing to fill up disk with recursive copy.

see https://github.com/claudiajs/claudia/blob/v2.9.0/src/commands/create.js#L53

if (source === os.tmpdir()) {
  return 'Source directory is the Node temp directory. Cowardly refusing to fill up disk with recursive copy.';
}

Adding --source /my/aws-lambda-image-directory does not help to resolve.

@mhuebner
Copy link
Author

mhuebner commented Mar 22, 2017

Ok, seems to be a problem with os.tmpdir() - this method returns the current working dir if run via npm. A workaround is to set TMPDIR environment variable:

"deploy": "TMPDIR=/tmp claudia create --profile $npm_package_config_profile --region $npm_package_config_region --version dev --handler index.handler --no-optional-dependencies --timeout $npm_package_config_timeout --memory $npm_package_config_memory -- --policies policies/*.json",

Have a look into this issue: npm/npm#4531

@kdybicz
Copy link
Collaborator

kdybicz commented Mar 27, 2017

Huh, this is really interesting case. Though I'm not sure, if we can merge that into our config, because of people usingnpm under Cygwin and also this being the root edge case. For sure it's worth checking if simple export TMPDIR=/tmp will work and keeping that workaround in docs or wiki.

Are you working here with Docker or is there any reason why you need to use root account?

@mhuebner
Copy link
Author

Yes, I am using a docker container (build my own based on wheezy-slim, nvm, ...) to have a clean environment.

I think it would be a good idea to mention the TMPDIR env var in the docs. export should work, too!

@lilltiger
Copy link

Also if you are running in a virtual environment /tmp is often mapped to a ram drive that uses the vm's memory. So if you are on an EC2 instance you might just have 1GB ram, and the deloy uses alot of memory and then it will create a zip that also eats memory because of it being on the ram-drive.
So insted of /tmp use another folder, and also set up a swap.

I had alot of issues with different failurs that I latter hunted down to the vm runing out of memory while deploying.

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