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.2 Gem Path Error for AWS SDK #98

Open
jaredSiebert opened this issue May 23, 2024 · 2 comments
Open

Ruby 3.2 Gem Path Error for AWS SDK #98

jaredSiebert opened this issue May 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jaredSiebert
Copy link

AWS Lambda with Ruby 3.2 error - by setting the GEM_PATH environment variable, the native aws-sdk gems cannot load

{
  "errorMessage": "cannot load such file -- aws-sdk-dynamodb",
  "errorType": "Init<LoadError>",
  "stackTrace": [
    "<internal:/var/lang/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:136:in `require'",
    "<internal:/var/lang/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:136:in `require'",
    "/var/task/handler.rb:1:in `<top (required)>'",
    "<internal:/var/lang/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:136:in `require'",
    "<internal:/var/lang/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:136:in `require'"
  ]
}

Additional context
As outlined in AWS docs for including gems from layers (https://docs.aws.amazon.com/lambda/latest/dg/ruby-package.html#ruby-package-dependencies-layers), if the generated zip file structure changes from ruby/3.2.0/* to ruby/gems/3.2.0/* then there is no need to set the GEM_PATH environment variable which will eliminate the issue of the native aws-sdk gems not being found.

Confirmed this works by compiling the deploy_http_nokogiri sample (https://navarasu.github.io/serverless-ruby-layer/#/use_docker), unzipping gemLayer.zip and adjusting the folder structure, zipping and manually uploading a custom layer to AWS.

@jaredSiebert jaredSiebert added the bug Something isn't working label May 23, 2024
@jaredSiebert
Copy link
Author

jaredSiebert commented May 23, 2024

Quick and dirty fix that I did

Starting at line 130

docker(['exec','-w',this.docker_gem_path, docker_id].concat(bundle_args),options,this.cli)
this.aws_gem_path = this.docker_gem_path+'/build/ruby/gems'
docker(['exec', docker_id, 'mkdir', this.aws_gem_path], options, this.cli)
docker(['exec', docker_id, 'mv', this.docker_gem_path+'/build/ruby/3.2.0', this.aws_gem_path], options, this.cli)
docker(['cp', '-L', container_id+':'+this.docker_gem_path+'/build/ruby', this.build_path], options, this.cli)

@jaredSiebert
Copy link
Author

Just following up on this - would be nice to not have to monkey patch each of my projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant