The elastic bean divider periodically activates the 1.5.2 rack, but for my Gemfile, the 1.6.0 rack is required

I am running the standard Rails 4.2.0 application on Elastic Beanstalk. The container is the 64-bit box of Amazon Linux 2014.09 v1.0.9 with Ruby 2.1.4, Puma 2.9.1, and Nginx 1.6.2.

When I paste the code into this environment, I get the following error in puma.log: "You have already activated rack 1.5.2, but your gemfile requires rack 1.6.0. Prepending bundle exec for your team can solve this."

I do not remember these errors a few months ago when I tested, and this seems intermittent. Sometimes I push, and everything works, sometimes I push, and it fails.

https://forums.aws.amazon.com/thread.jspa?messageID=599675 suggests that there may be an error in /opt/elasticbeanstalk/support/conf/puma.conf , but I fixed this file and the error still occurs . I also made sure that I needed to have puma and a stand in my gemfile.

What is the most ready-made and sustainable way to produce my EC2 instances to load the right rack version?

+5
source share
1 answer

After many trial and error, this is what worked for me.

Remove puma and rack with Gemfile . Run bundle install . This is what my Gemfile looks like.

 # Gemfile source 'https://rubygems.org' gem 'ahoy_matey' gem 'aws-sdk' gem 'bcrypt' gem 'cancancan' gem 'coffee-rails' gem 'font-awesome-rails' gem 'foundation-rails' gem 'gibbon' gem 'jbuilder' gem 'jquery-infinite-pages' gem 'jquery-rails' gem 'kaminari' gem 'mandrill_mailer' gem 'modernizr-rails' gem 'nokogiri' gem 'omniauth-facebook' gem 'omniauth-twitter' gem 'owlcarousel-rails' gem 'paper_trail' gem 'pg' gem 'rails' gem 'rails_admin' gem 'sanitize' gem 'sass-rails' gem 'sentry-raven' gem 'stripe' gem 'twitter-typeahead-rails' gem 'uglifier' gem 'whenever' group :test, :development do gem 'dotenv-rails' end group :development do gem 'spring' end group :doc do gem 'sdoc' end 

In the .ebextensions/ folder in your repo, create a script to install the 1.6.0 rack as a local gem.

 # .ebextensions/00-install-local-gems.config: commands: # add rack 1.6.0 to $GEM_ROOT so puma can activate it instead of rack 1.5.2 # use actual path not $GEM_ROOT because env vars are not available here # make sure puma and rack are not in app Gemfile or there will be blood 00_install_rack_160: command: gem install -i /opt/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0 rack -v 1.6.0 

Commit Gemfile , Gemfile.lock and .ebextensions/00-install-local-gems.config in your repo. Press the code on the elastic beanstalk.

You should now close all existing instances. The elastic Beanstalk will recreate them with this updated configuration.

I can confirm the above work with 64-bit Amazon Linux 2014.09 v1.2.0 and v1.0.9, both work with Ruby 2.1 (Puma).

+4
source

Source: https://habr.com/ru/post/1216424/


All Articles