title: Rails aws elastic beanstalk deploy error with database adapter
body: <p>I'm trying to deploy my rails application to aws elastic beanstalk, with guidance of this article.</p>
  
  <p><a href="https://medium.com/@jatescher/how-to-set-up-a-rails-4-2-app-on-aws-with-elastic-beanstalk-and-postgresql-3f9f29c046e2#.tnssj8z0o" rel="nofollow">https://medium.com/@jatescher/how-to-set-up-a-rails-4-2-app-on-aws-with-elastic-beanstalk-and-postgresql-3f9f29c046e2#.tnssj8z0o</a></p>
  
  <p>Before starting, "Using PostgreSQL with Rails" part, I had no problems. </p>
  
  <p>In that part, I followed the gemfile modifying, which adds the postgreSQL gem to the production group, and moves sqlite3 gem to the development &amp; test group, as I did other rails apps.</p>
  
  <p>Like this</p>
  
  <pre><code>group :development, :test do
     # Before insert this group, sqlite3 gem code is in the default group. (Outside of development group)
     gem 'sqlite3', '~&gt; 1.3.10' 
     ...other gems...
  end
  group :production do
     gem 'pg', '~&gt; 0.18.1'
  end
  </code></pre>
  
  <p>After then, I <code>$ bundle install</code>, <code>$ git commit</code>, and <code>$ eb deploy</code>. But in this time, EBS makes error with below messages</p>
  
  <blockquote>
    <p>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).</p>
    
    <p>Gem::LoadError: sqlite3 is not part of the bundle. Add it to Gemfile.</p>
    
    <p>Tasks: TOP => db:migrate => db:load_config (See full trace by running
    task with --trace).</p>
    
    <p>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.</p>
    
    <p>INFO: Command execution completed on all instances. Summary:
    [Successful: 0, Failed: 1].</p>
    
    <p>ERROR: Unsuccessful command execution on instance id(s) 'i-80ee5327'.
    Aborting the operation.</p>
    
    <p>ERROR: Failed to deploy application.</p>
  </blockquote>
  
  <p>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.</p>
  
  <pre><code>gem 'sqlite3', '~&gt; 1.3.10' 
  
  group :development, :test do
     ...other gems...
  end
  group :production do
     gem 'pg', '~&gt; 0.18.1'
  end
  </code></pre>
  
  <p>After that, the <code>$ eb deploy</code> command works well and server works.</p>
  
  <p>So, my question is... WHY this problem happens?</p>
  
  <p>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.</p>
  
  <p>Please help me...</p>
  
  <p>This is my current environment variables. </p>
  
  <pre><code> RACK_ENV = development 
   SECRET_KEY_BASE = **********
   RAILS_SKIP_MIGRATIONS = false 
   RAILS_SKIP_ASSET_COMPILATION = false
   BUNDLE_WITHOUT = test:development
  </code></pre>