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

Native extensions aren't being compiled #35

Open
kevinreedy opened this issue Oct 1, 2015 · 6 comments
Open

Native extensions aren't being compiled #35

kevinreedy opened this issue Oct 1, 2015 · 6 comments

Comments

@kevinreedy
Copy link

I'm attempting use grunt-aws-lambda for a project (https://github.com/kevinreedy/chef-asg-cleanup) that uses https://github.com/normanjoyner/chef-api. One of its dependencies is https://github.com/quartzjer/ursa, which has native extensions. When I run an npm install, the extensions are built! When I run grunt lambda_package, they are not. Steps to reproduce below:

$ git clone git@github.com:kevinreedy/chef-asg-cleanup.git
$ cd chef-asg-cleanup/
$ npm install
[output snipped]
$ grunt lambda_package
Running "lambda_package:default" (lambda_package) task
chef-asg-cleanup@0.1.0 ../../../tmp/1443742405683.5662/node_modules/chef-asg-cleanup
Created package at ./dist/chef-asg-cleanup_0-1-0_2015-9-1-23-33-25.zip

Done, without errors.
$ cd dist
$ unzip chef-asg-cleanup_0-1-0_2015-9-1-23-33-25.zip
[output snipped]
$ cd ..
root@8dd621056992:/usr/src/app# ls node_modules/chef-api/node_modules/ursa/build
Makefile  Release  binding.Makefile  config.gypi  ursaNative.target.mk
root@8dd621056992:/usr/src/app# ls dist/node_modules/chef-api/node_modules/ursa/build
ls: cannot access dist/node_modules/chef-api/node_modules/ursa/build: No such file or directory

I imagine there's an option that is needed to pass into npm.commands.install (https://github.com/Tim-B/grunt-aws-lambda/blob/master/tasks/lambda_package.js#L59-L66) to ensure that node-gyp gets called, but it's not obvious from looking at npm's code. Any thoughts to push me in the right direction? Thanks!

@Tim-B
Copy link
Owner

Tim-B commented Oct 3, 2015

Thanks for bringing this up.

I can imagine this will be a complicated to resolve if you're developing on an environment that doesn't match the Lambda environment (eg. developing on Windows and running on Lambda/Linux).

Perhaps you could manually build binaries then include them in the correct folder using something like the include_files option.

If you unzip the generated package and run npm build does it work?

@kevinreedy
Copy link
Author

I've been using a Docker container to do the build, so that it'll actually build correctly for lambda. As for running npm build . in the root after unzipping the package, it doesn't do anything. But, if I cd node_modules/chef-api/node_modules/ursa && npm build ., it will do the build of the native extensions for that nested requirement.

@kevinreedy
Copy link
Author

I was able to get around this using the include_files option for now. It looks like that doesn't include recursively though, so I'm getting a bit verbose. https://github.com/kevinreedy/chef-asg-cleanup/blob/master/Gruntfile.js#L18-L29

@aheissenberger
Copy link

@kevinreedy can you share your docker file which simulates the lambda environment - at the moment I use a ec2 instance and this would make it much easier to build the node modules with binary parts (iconv, fibers) - thanks

@dcrockwell
Copy link

@kevinreedy @aheissenberger @Tim-B,

I've made a library that may help with these kinds of issues: https://github.com/FreeAllMedia/akiro

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

4 participants