Don't run Bundler as root - Rails6 on Elastic Beanstalk

Viewed 1834

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
1 Answers

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

Related