I'm trying to deploy my rails application to aws elastic beanstalk, with guidance of this article.
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