rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

Ensure Bundler Available on AWS Lambda: Bundle error After deploy #151

Closed efreesen closed 5 years ago

efreesen commented 5 years ago

Checklist

My Environment

Software Version
Operating System MacOS X 10.13.6
Jets 1.5.6
Ruby 2.5.3

Expected Behaviour

After deploy the API should work properly and respond accordingly.

Current Behavior

The lambda function returns the following error:

cannot load such file -- bundler/setup

With the following stacktrace

Init error when loading handler handlers/controllers/api_controller.index
{
  "errorMessage": "cannot load such file -- bundler/setup",
  "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/handlers/controllers/api_controller.rb:1: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'"
  ]
}
START RequestId: 3e6be219-1bef-40ae-b948-9e8b3831a03b Version: $LATEST

Step-by-step reproduction instructions

Clone the following project, deploy it to AWS Lambda and try to access the /api endpoint.

Code Sample

https://github.com/efreesen/jets-bundler-bug

Solution Suggestion

It seems the app cannot find the bundler gem, I tried to add the bundler into the zip but it didn't work.

The solution I see is to pack the bundler with the other dependencies if this is really the problem.

tongueroo commented 5 years ago

Thanks for the example project. Noticed that the bundler version you are using is 1.17.2. Looks like I'm on version 2.0.1

-   2.0.1
+   1.17.2

Wondering if you can give updating a shot:

gem install bundler
rm -f Gemfile.lock
bundle update # to update Gemfile.lock in the project

Check that Gemfile.lock has the updated bundler version afterwards.

Sounds like you’re right and will have to figure how to make sure we’re running a version of bundler available on AWS Lambda.

efreesen commented 5 years ago

Thank you for the amazing job with this framework!

Updated the project with the correct bundler version.

Yup, maybe if you add support for 2.6.0 this problem is gone as bundler is integrated. 😃

jkthorne commented 5 years ago

I am still having problems with this :(

tongueroo commented 5 years ago

@wontruefree Yup. Think this is related https://discuss.circleci.com/t/bundler-2-0-was-released-and-bundler-may-not-be-happy/27521

Unsure why it was working even yesterday but fix is in #155 Testing it out now.

tongueroo commented 5 years ago

Released in v1.5.8 CHANGELOG

jkthorne commented 5 years ago

@tongueroo I found out there was a local cache causing problems. When I cleared the cache it worked.

tongueroo commented 5 years ago

Oh I see. Good to know. Thanks for posting for others. Think the latest release will also help also.

Also for posterity and others, to fully blow away the entire cache.

rm -rf /tmp/jets