0

I am trying to deploy a rails app to elastic beanstalk but getting an error.

INFO: Environment update is starting.                               
INFO: Deploying new version to instance(s).                         
ERROR: [Instance: i-053f6b1dfef0f156b] Command failed on instance. Return code: 1 Output: (TRUNCATED)...arrierwave.rb:2:in `block in <top (required)>'
/var/app/ondeck/config/initializers/carrierwave.rb:1:in `<top (required)>'
/var/app/ondeck/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace). 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-053f6b1dfef0f156b'. Aborting the operation.
ERROR: Failed to deploy application.                                

ERROR: Failed to deploy application.

Don't know why I am getting this Carrierwave error. I have that file to work with S3 to upload photos.

carrierwave.rb

CarrierWave.configure do |config|
    config.fog_credentials = {
        provider: "AWS",
        aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
        aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
    }
    config.fog_directory = ENV["AWS_S3_BUCKET"]
end

environment.rb

# Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Rails.application.initialize!

Here is the log:

enter image description here

EDIT HERE:

 ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
  /var/app/ondeck/config/initializers/carrierwave.rb:2:in `block in <top (required)>'
  /var/app/ondeck/config/initializers/carrierwave.rb:1:in `<top (required)>'
  /var/app/ondeck/config/environment.rb:5:in `<top (required)>'
  Tasks: TOP => environment

EDIT2 my part of the gem file;

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

and I created the RDS with postgresql. database.yml file;

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: <%= ENV['RDS_DB_NAME'] %>#db/production.sqlite3
  username: <%= ENV['RDS_USERNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  port: <%= ENV['RDS_PORT'] %>

getting an error of ;

ERROR: [Instance: i-053f6b1dfef0f156b] Command failed on instance. Return code: 1 Output: (TRUNCATED)...sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

Gem::LoadError: sqlite3 is not part of the bundle. Add it to Gemfile.

why should I add gem sqlite3?, I have it already in development and should use in production. That is how Heroku works. I thought the same for elastic beanstalk

7
  • See the log: /var/log/eb-activity.log. What does it say? Commented May 26, 2016 at 18:51
  • sorry, how do I go there? Commented May 26, 2016 at 18:51
  • As the message says: using console or EB CLI. Or, just google it. Commented May 26, 2016 at 18:53
  • Ok, saw the problem and try to solve it. Thank you Commented May 26, 2016 at 19:03
  • but the problem is I have declared in application.yml file Commented May 26, 2016 at 19:10

2 Answers 2

0

I had the same issue. I found out two problems:

  1. AWS environment variables missing (required by CarrierWave) in the environment (which prevents rake assets:precompile during the creation).
  2. Missing sqlite3 in Gemfile's production (which is required by EB).

You need to configure AWS environment variables when creating the environment:

eb create [app_name] -v --envvars AWS_ACCESS_KEY_ID=[access_key], AWS_ACCESS_KEY_SECRET=[key_secret]` 

Event though you are using PostgreSQL as your database in AWS RDS, and you have specified it in Gemfile and database.yml, EB still requires sqlite3. Maybe for its own usage. So just add sqlite3 to Gemfile's production block.

Sign up to request clarification or add additional context in comments.

Comments

0

Remove the <<: *default from the first line of your production: in your database.yml file. It its causing you chaos b/c in default you're saying sqlite3 then in the next 5 lines you're providing postgres info.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.