Installing gems fails in deployment – AWS Elastic Beanstalk

Question:

The native gems are not installing while I try to deploy the app in AWS Elastic Beanstalk(EB) environment.

eb-activity.log

I tried the following:

  1. updating bundler using gem update bundler command in EB /var/app/current directory and the is no improvements.
  2. Removing gemfile.lock and bundle install in local and deployed updated gemfile.lock.

The same above error occurs everytime.

I am using Rails 4.2.4 with ruby 2.3 version.

Please help me. Thanks.

Answer:

I finally solved the issue by caching the gem.

I ran bundle package in local and it creates the gem caches in the vendor/cache directory.

Now, while deploying in AWS with those cached gems it tries to use the cached gem instead of installing it. I don’t know whether it is a good practice but, it solved my issue.

I got this solution from the AWS blog: Locally Packaging Gem Dependencies for Ruby Applications in Elastic Beanstalk

Edit #1: Adding @sybind’s comment in answer

bundle package --all will include all :git references

If there is any better solution please let me know.

Leave a Reply