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

Ruby 3.0 Support? #14

Open
metaskills opened this issue May 10, 2021 · 9 comments
Open

Ruby 3.0 Support? #14

metaskills opened this issue May 10, 2021 · 9 comments

Comments

@metaskills
Copy link

Now that Ruby 2.5 is on its way out, I am hoping that at some point in time there is an official Ruby 3.0 Runtime. Am I correct that this runtime interface will have to be updated at well? I ran the unit tests and only saw this one time format error.

  1) Failure:
HarnessTests#test_dependencies [/Users/kencollins/Repositories/aws-lambda-ruby-runtime-interface-client/test/unit/harness_test.rb:88]:
--- expected
+++ actual
@@ -1 +1 @@
-"{\"tomorrow\":\"2018-10-09T11:34:20.000+01:00\"}"
+"{\"tomorrow\":\"2018-10-09 11:34:20 +0100\"}"
@djpate
Copy link
Contributor

djpate commented Jul 26, 2021

We've been using it on prod. No issues so far.

@jstefek
Copy link

jstefek commented May 23, 2022

When using with ruby 3.1 I get following error after the execution of my function finishes:

Critical exception from handler
{
"errorMessage": "uninitialized constant #<Class:AwsLambda::Marshaller>::StringIO\n\n        when StringIO, IO\n             ^^^^^^^^",
"errorType": "Function<NameError>",
"stackTrace": [
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric/aws_lambda_marshaller.rb:27:in `marshall_response'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric/lambda_handler.rb:31:in `call_handler'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric.rb:81:in `run_user_code'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric.rb:59:in `start_runtime_loop'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric.rb:42:in `run'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric/bootstrap.rb:35:in `bootstrap_handler'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric/bootstrap.rb:8:in `start'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/bin/aws_lambda_ric:10:in `<top (required)>'",
"/some/path/vendor/bundle/ruby/3.1.0/bin/aws_lambda_ric:25:in `load'",
"/some/path/vendor/bundle/ruby/3.1.0/bin/aws_lambda_ric:25:in `<main>'"
]
}
Init error when loading handler
{
"errorMessage": "wrong number of arguments (given 4, expected 2..3)",
"errorType": "Init<ArgumentError>",
"stackTrace": [
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric.rb:109:in `send_error_response'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric.rb:98:in `rescue in run_user_code'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric.rb:77:in `run_user_code'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric.rb:59:in `start_runtime_loop'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric.rb:42:in `run'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric/bootstrap.rb:35:in `bootstrap_handler'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/lib/aws_lambda_ric/bootstrap.rb:8:in `start'",
"/some/path/vendor/bundle/ruby/3.1.0/gems/aws_lambda_ric-2.0.0/bin/aws_lambda_ric:10:in `<top (required)>'",
"/some/path/vendor/bundle/ruby/3.1.0/bin/aws_lambda_ric:25:in `load'",
"/some/path/vendor/bundle/ruby/3.1.0/bin/aws_lambda_ric:25:in `<main>'"
]
}

so I had to set Retry attempts to 0 for the lambda.

Seems like monkey patch as mentioned here: #15 works.
I had to add to my handler following:

require 'aws_lambda_ric'
require 'io/console'
require 'stringio'

module AwsLambdaRuntimeInterfaceClient
  class LambdaRunner

    def send_error_response(lambda_invocation, err, exit_code = nil, runtime_loop_active = true)
      error_object = err.to_lambda_response
      @lambda_server.send_error_response(
        request_id: lambda_invocation.request_id,
        error_object: error_object,
        error: err,
        xray_cause: XRayCause.new(error_object).as_json
      )

      @exit_code = exit_code unless exit_code.nil?
      @runtime_loop_active = runtime_loop_active
    end
  end
end

@rberger
Copy link

rberger commented Sep 29, 2022

I'm not clear if the current lambda runtime does support Ruby 3.x or not. This thread seems to be saying it does, but the README says:

The Ruby Runtime Interface Client package currently supports Ruby versions:

  • 2.5.x up to and including 2.7.x

@rberger
Copy link

rberger commented Nov 17, 2022

Will there ever be Ruby 3.x support?

@rberger
Copy link

rberger commented Dec 1, 2022

If Ruby 3x support is not imminent, any pointers on building a custom ruby 3 runtime?

@rjhornsby
Copy link

If Ruby 3x support is not imminent, any pointers on building a custom ruby 3 runtime?

Ruby 2.7 is EOL in 3 months. Ruby 3.0 was released GA two years ago. I hesitate to throw my hands up and say we're not getting Ruby 3.x support for our Lambda functions, but it certainly seems like if it was going to be a thing it should have been done by now.

Two years after the GA release I think we can safely agree that Ruby 3.0 isn't bleeding edge. I also understand that NodeJS and Python are all the rage (and there's nothing wrong with Python), but I have to imagine that we're far from alone in being a mostly Ruby shop because we're a Chef shop - which naturally means also doing most of our non-chef work in Ruby.

@metaskills
Copy link
Author

metaskills commented Dec 4, 2022

I can confirm this gem works fine with any modern Ruby I have thrown at it. We use the Ruby RIC for all our K8s images to get EventBridge rules. I also updated the Rails on Lambda (Lamby) cokoiecuter project using Debian images with the RIC on Ruby 3.1, works great. rails-lambda/lamby-cookiecutter#21

Hope that helps!

@dimasusername
Copy link

Ruby 3 aside, we desperately need a fresh release, monkey-patching fixes as mentioned here (kudos to @jstefek) is not the way to go

@wildodecisiv
Copy link

Hello Everyone!
Recently in my team we were planning to upgrade all our serverless app from ruby 2.7 (native runtime) to 3.2 (using docker container), however we recently received an email from AWS Support saying that they will add native runtime support for Ruby 3.2 at the end of Q2 2023.
In the same way, I want to share with you a simple HelloWorld project using AWS SAM, Rbenv + Ruby 3.2.1 and Docker, hope it helps to someone that will decide to still use this approach instead to wait the native support

https://github.com/wildomonges/lambda-ruby3.2-container-image

Kind Regards!

ErikSchierboom referenced this issue in exercism/image-generator Aug 2, 2023
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

7 participants