ElasticBeanstalk - Rails Nokogiri Deployment Issue

2019-07-18 23:17发布

问题:

I have a working rails application deployed to EC2 through ElasticBeanstalk. I update the website every few weeks without issue. Today I'm running into a problem after committing changes and running "eb deploy":

An error occurred while installing nokogiri (1.7.0.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.7.0.1'` succeeds before bundling.

I haven't changed anything aside from a few views. The host is the same and the Gemfile is the same. On my local machine, I can run that command and then bundle install/update without issue. I can SSH to the EC2 host and successfully run that command to install that version of Nokogiri, too.

When I deploy, I get that error message (with no other details). I'm stuck - Any idea what I should look into next? Note that this started happening to a working setup, so I don't think it's the host missing libxml or another dependency.

回答1:

Found it. There was a line in the log file that I was missing.

"Cannot allocate memory"

Rails was using a lot more memory than I thought. Just sitting there it was using 1.7GB out of 2.0GB. I temporarily added 1GB of swap and the deployment succeeded.