Open DerWanderer opened 4 months ago
I believe the mysql2 gem has additional requirements. See the Installation instructions it its readme:
You may need to install a package such as libmariadb-dev, libmysqlclient-dev, mysql-devel, or other appropriate package for your system
Have you confirmed that the target system has the appropriate mysql client?
See https://github.com/customink/mysql2-lambda?tab=readme-ov-file, which is archived, but points to https://github.com/rails-lambda/lamby-cookiecutter/pull/21 for building your own ruby lambda runtime with the mysql client installed.
Aha, thank you @joshuaflanagan. That actually rings a bell from years ago. I'm sure that the AWS Lambda image for Ruby 3.2 will not have the mysql client pre-installed. I will look into this and report back.
I am testing a very basic service (based on https://github.com/serverless/examples/tree/v3/aws-ruby-simple-http-endpoint) using the serverless-ruby-package. It's been working perfectly as I carefully add more of my requirements to it. Execution started failing as soon as I added the
gem 'mysql2'
to the Gemfile. Here is the error in Cloudwatch:The mysql2.so file was built within the image and is present in the Docker image, in the vendor/ files, and is visible in the AWS Lambda console "Code" tab. Rebuilding the gems with Ruby 3.3 and deploying with the 3.3 Docker image also resulted in the same problem.
Serverless.yml excerpt:
Environment:
Docker Image (command "docker image ls"): amazon/aws-lambda-ruby 3.2 3f8c5310dbf8 11 days ago 683MB Ruby: RVM using Ruby 3.2.3