AWS Elastic Beanstalk Rails Bundler Failed
I am using eb CLI to install my rails app on AWS. I used to have a test one, but now I am trying to deploy some actual code that I wrote. When I execute git aws.push the update fails. The "eb logs" command shows that the provider has failed.
I am running this on Amazon Linux 2014.03 v1.0.0 64-bit with Ruby 2.1 (Puma)
Fetching source index from https://rubygems.org/
Using rake (10.3.2)
Using i18n (0.6.11)
Using minitest (4.7.5)
Using multi_json (1.10.1)
Using thread_safe (0.3.4)
Using tzinfo (0.3.41)
Using activesupport (4.0.8)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.8)
Using mime-types (1.25.1)
Using polyglot (0.3.5)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.8)
Using activemodel (4.0.8)
Using active_model_serializers (0.9.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using activerecord (4.0.8)
Using addressable (2.3.6)
Using execjs (2.2.1)
Using autoprefixer-rails (3.0.1.20140826)
Installing bcrypt (3.1.7)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/opt/rubies/ruby-2.1.2/bin/ruby extconf.rb
Cannot allocate memory - /opt/rubies/ruby-2.1.2/bin/ruby extconf.rb 2>&1
Gem files will remain installed in /opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7 for inspection.
Results logged to /opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0-static/bcrypt-3.1.7/gem_make.out
An error occurred while installing bcrypt (3.1.7), and Bundler cannot continue.
Make sure that `gem install bcrypt -v '3.1.7'` succeeds before bundling.
2014-09-03 00:22:36,561 [ERROR] (3331 MainThread) [directoryHooksExecutor.py-33] [root directoryHooksExecutor error] Script /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed with returncode 5
I am not calling bcrypt on my gem file. It must be addiction to the gem of witchcraft.
I tried using the "package bundle" for the vendor / cache trick, but it kept saying that some gems were missing from AWS. As you can tell, I'm pretty new to not only elastic beanstalk / aws but rails, so I might just be doing something totally wrong.
Also, when I remove the bcrypt references (which I'm sure will break something) in the gemfile.lock, it just throws the same error on a different gem later (ffi). I'm sure there are many gems out there that will end up causing an error if I manage to fix the problem with only one gem at a time.
source to share
The error is actually caused by running out of memory when starting the instance:
Cannot allocate memory - /opt/rubies/ruby-2.1.2/bin/ruby extconf.rb 2>&1
You are most likely using a micro instance - scale it up to a larger instance size and it should build reliably.
Rohit is correct, although in his answer that missing system packages are often the reason gems cannot be installed in Elastic Beanstalk.
source to share
Thus, there might be some dependencies on the C libraries that are required for gem install bcrypt -v '3.1.7'
. You can install your own dependencies using yum and ebextensions.
You can use ebextensions to install yum packages required for gem to install successfully. Create a file .ebextensions/01-yum.config
in application source and put the following content in it.
packages:
yum:
<required-native-dependency>: []
This file is in YAML format, so it is important to be indented.
More on the pacakges section in the following examples:
source to share