3

I've been trying to deploy a Rails 6 application to Elastic Beanstalk and have been stuck with this Bundle Root error for over a day. I've read through everything I can find but nothing has worked so far.

[ERROR] An error occurred during execution of command [app-deploy] - [stage ruby application]. Stop running the command. Error: install dependencies in Gemfile failed with error Command /bin/sh -c bundle install --local failed with error Command timed out after 900 seconds. Stderr:Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.

My gemfile:

git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.3'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'

gem 'sendgrid-ruby'

gem 'faker'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

gem 'will_paginate', '~> 3.1.0'
gem 'bootstrap-will_paginate', '1.0.0'

gem 'sprockets', '~> 4.0'

gem 'devise'

gem 'bootstrap'

gem 'jquery-rails'

gem 'figaro'

gem 'rails-controller-testing'

gem 'validates_zipcode'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]

gem 'minitest'
gem 'minitest-reporters'

end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', '>= 1.2016.7'

my .ebextension/fix_rails_6.config:

packages:
    yum:
        git: []

commands:
  02_download_nodejs:
    command: "curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -"
  03_install_nodejs:
    command: "yum -y install nodejs"

container_commands:
  19_precompile:
    command: "bundle exec rake assets:precompile"

And my environment properties:

BUNDLER_DEPLOYMENT_MODE true
BUNDLE_WITHOUT   test:development
RACK_ENV production
RAILS_SKIP_ASSET_COMPILATION true
RAILS_SKIP_MIGRATION false
downtownott
  • 31
  • 1
  • 3
  • I don't think the "don't run bundler as root" is an actual problem. It's really just a warning. Can you download the logs through the Elastic Beanstalk console and see if you can get more information on errors? It looks like it is stuck on installing a Gem. Check the log file to see which one it is getting stuck on. – littleforest Nov 17 '20 at 20:07
  • There is this error but I've ignored it as I upgraded everything to 5.0.4 yesterday. Both the AWS server and my code (including Gemfile.lock) are all now 5.0.4```opt/rubies/ruby-2.7.2/lib/ruby/site_ruby/2.7.0/bundler/runtime.rb:312:in `check_for_activated_spec!': You have already activated puma 5.0.4, but you r Gemfile requires puma 4.3.6. Prepending bundle exec to your command may solve this. (Gem::LoadError)``` – downtownott Nov 17 '20 at 20:25
  • Ok - I'm going to dig in a bit more, it seems to be hanging on nio4r, which has some relationship with puma? – downtownott Nov 17 '20 at 20:35
  • I would suggest terminating the existing server and having it spin up a new instance, or use the Immutable deployment policy for the short-term so you can deploy on a clean instance each time until you have your issues worked out. – littleforest Nov 17 '20 at 21:28
  • @downtownott did you ever get it up and running? I'm experiencing the same error. – Grambo Dec 27 '20 at 04:08
  • Grambo I terminated the server as recommended but ran into similar but different issues. I did this a few more times with different problems each time and ultimately gave up. Sticking with Heroku for now and planning to use Hatchbox.io when I need something more sophisticated – downtownott Dec 29 '20 at 21:45
  • I am running into similar issue here: https://stackoverflow.com/questions/68494462/build-fails-when-deploying-rails-application-on-amazon-linux-2 – Puneet Pandey Aug 02 '21 at 06:49

1 Answers1

0

I'm guessing that you have an old, out-of-date Gemfile.lock on the deployed server which has incorrect versions of your Gems listed.

If this builds and runs locally, I would suggest ensuring that you distribute the Gemfile.lock file to your server along with the rest of the code and the Gemfile.

If that doesn't work, remove the Gemfile.lock from your deployed server and try again

Dan Leyden
  • 319
  • 1
  • 4