Quantcast
Channel: Active questions tagged aws-lambda - Stack Overflow
Viewing all articles
Browse latest Browse all 3999

Cannot load file mysql2 on AWS Lambda

$
0
0

Trying to have a Lambda connect to an RDS database but can't get the mysql2 gem to load. Tried the pristine instruction but that didn't resolve the issue.

I've got the built mysql2 gem in the vendor directory. Did this using bundle install --deployment.

Presumably this is a problem because of the compiled extensions used by mysql2. Not sure how I can sort this for AWS Lambda though. Thoughts?

Here's the log output:

START RequestId: 62f35c49-039f-11e9-be04-1fd1111df42b Version: $LATESTIgnoring mysql2-0.5.2 because its extensions are not built. Try: gem pristine mysql2 --version 0.5.2Init error when loading handler lambda_function.lambda_handler{"errorMessage": "cannot load such file -- mysql2","errorType": "Init<LoadError>","stackTrace": ["/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'","/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'","/var/task/lambda_function.rb:3:in `<top (required)>'","/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'","/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'"  ]}END RequestId: 62f35c49-039f-11e9-be04-1fd1111df42bREPORT RequestId: 62f35c49-039f-11e9-be04-1fd1111df42b  Duration: 1439.17 ms    Billed Duration: 1500 ms    Memory Size: 128 MB Max Memory Used: 17 MB  Unknown application error occurredInit<LoadError>

Here's my Gemfile:

source 'https://rubygems.org'gem 'mysql2', '~> 0.5.2'gem 'sequel', '~> 5.15.0'

Gemfile.lock

GEMremote: https://rubygems.org/specs:  mysql2 (0.5.2)  sequel (5.15.0)PLATFORMS  rubyDEPENDENCIES  mysql2 (~> 0.5.2)  sequel (~> 5.15.0)BUNDLED WITH  1.17.2

Here's the top of my lambda_function.rb file

require 'json'require 'logger'require 'mysql2'require 'sequel'

Viewing all articles
Browse latest Browse all 3999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>