4

I'm trying to deploy my rails application to aws elastic beanstalk, with guidance of this article.

https://medium.com/@jatescher/how-to-set-up-a-rails-4-2-app-on-aws-with-elastic-beanstalk-and-postgresql-3f9f29c046e2#.tnssj8z0o

Before starting, "Using PostgreSQL with Rails" part, I had no problems.

In that part, I followed the gemfile modifying, which adds the postgreSQL gem to the production group, and moves sqlite3 gem to the development & test group, as I did other rails apps.

Like this

group :development, :test do
   # Before insert this group, sqlite3 gem code is in the default group. (Outside of development group)
   gem 'sqlite3', '~> 1.3.10' 
   ...other gems...
end
group :production do
   gem 'pg', '~> 0.18.1'
end

After then, I $ bundle install, $ git commit, and $ eb deploy. But in this time, EBS makes error with below messages

ERROR: [Instance: i-80ee5327] 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.

Tasks: TOP => db:migrate => db:load_config (See full trace by running task with --trace).

Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.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-80ee5327'. Aborting the operation.

ERROR: Failed to deploy application.

By reading error messages, I catch that the sqlite3 gem is not loadded by aws instance, so I put out the sqlite3 gem code to outside of development group.

gem 'sqlite3', '~> 1.3.10' 

group :development, :test do
   ...other gems...
end
group :production do
   gem 'pg', '~> 0.18.1'
end

After that, the $ eb deploy command works well and server works.

So, my question is... WHY this problem happens?

In my thought, if I make gemfile like 2nd version, sqlite3 adapter is loaded by default environment and should be crashing in production environment. But the result is completely opposite to me. This is very annoying situation and, to be more, I'm in doubt whether I'm doing the right solution.

Please help me...

This is my current environment variables.

 RACK_ENV = development 
 SECRET_KEY_BASE = **********
 RAILS_SKIP_MIGRATIONS = false 
 RAILS_SKIP_ASSET_COMPILATION = false
 BUNDLE_WITHOUT = test:development
3
  • 1
    what's in the config/database.yml? Commented Jan 26, 2016 at 16:16
  • can you remove "<<: *default" under production and see what happens? Commented Jan 26, 2016 at 17:24
  • @jae555 I'm get twisted within modifying code and explain it. After I wrote this question, I constantly fight with other installation bugs and now I totally lost. It's annoying situation but I just bare with it.... Thank you. Commented Jan 26, 2016 at 18:05

1 Answer 1

6

it appears you're running your beanstalk server in development mode. make sure you have the following env variables set in beanstalk:

RAILS_ENV=production
RACK_ENV=production
Sign up to request clarification or add additional context in comments.

2 Comments

Problem solved! Your solution very works well. By the way, what's the difference between RAILS_ENV and RACK_ENV? I didn't see any articles about configuring RAILS_ENV. I thought that RACK_ENV is related to rails environment, but RAILS_ENV is the right one.
@casamia if it is right answer and helped you, please accept it so other can use it as well with more confident.

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.