joshuaflanagan / serverless-ruby-package

serverless plugin to package ruby gems
39 stars 11 forks source link

Cannot Find Gems in 3.2 Runtime when bundled in lambci/lambda:build-ruby2.7 #55

Closed nodanaonlyzuul closed 1 year ago

nodanaonlyzuul commented 1 year ago

Hi @joshuaflanagan

Firstly - THANK YOU for this plugin. It's really simplified our build and deploy strategies. It's great. I appreciate the work you and other contributors have put into it.

Cannot Find Gems in Deployed 3.2 Runtime

We recently updated a serverless project's runtime to ruby3.2 - and once it was deployed, it couldn't find gems. A bit of digging uncovered that while the gems bundled (in the ephemeral lambci/lambda:build-ruby2.7 image) into vendor/bundle/ruby/2.7.0/...the setup.rb reads as:

require 'rbconfig'
ruby_engine = RUBY_ENGINE
ruby_version = RbConfig::CONFIG["ruby_version"]
path = File.expand_path('..', __FILE__)
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/aws-eventstream-1.1.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/aws-partitions-1.380.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/aws-sigv4-1.2.2/lib"

So in the runtime RbConfig::CONFIG["ruby_version"] will be evaluated as "3.2.0" - and the $LOAD_PATH array won't will build paths like:

.../2.7.0/gems/aws-eventstream-1.1.0/lib instead of the correct .../3.2.0/gems/aws-eventstream-1.1.0/lib.

Does that make sense / jive with your experience?

Using a Maintained Image for Building

lambci/lambda is deprecated. They won't be building a 3.2 image. Has there been any investigation into switching this repo to use the aws/aws-lambda-base-images images per lambci/lambda's deprecation suggestion?

joshuaflanagan commented 1 year ago

Have you upgraded to the 3.2 version of this plugin? It includes these changes https://github.com/joshuaflanagan/serverless-ruby-package/pull/51 which added first class support for ruby 3.2, and switches to the official AWS container images.

Please let me know if there is still an issue after using the updating the plugin.

nodanaonlyzuul commented 1 year ago

DOH! That would do it....I've been cruising on 1.4.0 for a long time. Too long. I've redeployed - this lambda will invoke over the weekend.

In the meantime - thanks for the response and apologies for not digging into the closed issues or latest in master.

nodanaonlyzuul commented 1 year ago

It invoked. It worked just fine. Apologies again . THANK YOU.