title: can't run rake or rails console on vps
body: <p>I have a demo Rails app up and running on a VPS thanks to Ryan Bates' deploying to a VPS episode on Railscasts. On my server I created a directory structure like this <code>/home/username/apps</code> and the application was deployed to <code>/home/username/apps/appname.</code> Inside the app name folder are three more folders created by Ryan's script (I presume)</p>
  
  <pre><code>current  releases  shared
  </code></pre>
  
  <p>and inside the <code>current</code> folder is the usual Rails directory. If I cd into the <code>current</code> folder and run <code>rails c</code> or <code>rake db:seed</code> I get the error</p>
  
  <pre><code> configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
  </code></pre>
  
  <p>being triggered from the shared directory</p>
  
  <pre><code> apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters
  </code></pre>
  
  <p>I find this an unusual error to get since the demo application (which is scaffolding) is saving newly created entries and listing them out, so I'm assuming there's something wrong with how I'm trying to run rake and rails console commands rather than something wrong with my declaration of the adapter.</p>
  
  <p>Can you tell me what it might be?</p>
  
  <p>Note, there's already a question <a href="https://stackoverflow.com/questions/413659/database-configuration-does-not-specify-adapter">database configuration does not specify adapter</a> that deals with this general topic, however, the answers to that question seem to deal with situations where the database isn't working at all, however, in my situation it seems that's not the case. Therefore, I distinguish this question from that thread. </p>
  
  <p>This is my database.yml file</p>
  
  <pre><code>production:
    adapter:  postgresql
    encoding:  unicode
    database:  dodeploy_production
    pool:  5
    host:  localhost
    username:  michael
    password:  secretpassword
  </code></pre>
  
  <p>This is the script Ryan uses to deploy. I'm including it because maybe there's some information in here that will help you understand something I'm missing. </p>
  
  <pre><code>require "bundler/capistrano"
  
  server "198XXXX", :web, :app, :db, primary: true
  
  set :application, "dodeploy"
  set :user, "michael"
  set :deploy_to, "/home/#{user}/apps/#{application}"
  set :deploy_via, :remote_cache
  set :use_sudo, false
  
  set :scm, "git"
  set :repository, "git@github.com:Username/appname.git"
  set :branch, "master"
  
  default_run_options[:pty] = true
  ssh_options[:forward_agent] = true
  
  after "deploy", "deploy:cleanup" # keep only the last 5 releases
  
  namespace :deploy do
    %w[start stop restart].each do |command|
      desc "#{command} unicorn server"
      task command, roles: :app, except: {no_release: true} do
        run "/etc/init.d/unicorn_#{application} #{command}"
      end
    end
  
    task :setup_config, roles: :app do
      sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
      sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
      run "mkdir -p #{shared_path}/config"
      put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
      puts "Now edit the config files in #{shared_path}."
    end
    after "deploy:setup", "deploy:setup_config"
  
    task :symlink_config, roles: :app do
      run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
    end
    after "deploy:finalize_update", "deploy:symlink_config"
  
    desc "Make sure local git is in sync with remote."
    task :check_revision, roles: :web do
      unless `git rev-parse HEAD` == `git rev-parse origin/master`
        puts "WARNING: HEAD is not the same as origin/master"
        puts "Run `git push` to sync changes."
        exit
      end
    end
    before "deploy", "deploy:check_revision"
  end
  </code></pre>
  
  <p>Error</p>
  
  <p>When I run <code>rails c</code> (or <code>rake db:seed</code>) I'm getting this </p>
  
  <pre><code>home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:52:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:30:in `spec'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/connection_handling.rb:39:in `establish_connection'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/railtie.rb:170:in `block (2 levels) in &lt;class:Railtie&gt;'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/lazy_load_hooks.rb:44:in `each'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/base.rb:322:in `&lt;module:ActiveRecord&gt;'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/base.rb:22:in `&lt;top (required)&gt;'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:in `require'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:in `block in require'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:213:in `load_dependency'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:in `require'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/activerecord-4.0.0.rc2/lib/active_record/railtie.rb:61:in `block in &lt;class:Railtie&gt;'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/railtie.rb:188:in `call'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/railtie.rb:188:in `block in run_console_blocks'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/railtie.rb:188:in `each'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/railtie.rb:188:in `run_console_blocks'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/application.rb:264:in `block in run_console_blocks'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/engine/railties.rb:17:in `each'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/engine/railties.rb:17:in `each'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/application.rb:264:in `run_console_blocks'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/engine.rb:431:in `load_console'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/commands/console.rb:51:in `initialize'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/commands/console.rb:9:in `new'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/commands/console.rb:9:in `start'
      from /home/michael/apps/dodeploy/shared/bundle/ruby/1.9.1/gems/railties-4.0.0.rc2/lib/rails/commands.rb:66:in `&lt;top (required)&gt;'
      from bin/rails:4:in `require'
      from bin/rails:4:in `&lt;main&gt;'
  </code></pre>
  
  <p>Update</p>
  
  <p>I wasn't sure why Ryan created database.example.yml in the Railscast. He didn't configure it and I just left it as a copy of the original database.yml file before I added the username and password. </p>
  
  <p>database.example.yml</p>
  
  <pre><code>development:
    adapter: postgresql
    encoding: unicode
    database: dodeploy_development
    pool: 5
    password:
  test:
    adapter: postgresql
    encoding: unicode
    database: dodeploy_test
    pool: 5
    password:
  
  production:
    adapter: postgresql
    encoding: unicode
    database: dodeploy_production
    pool: 5
    password:
  </code></pre>
  
  <p>This is the nginx.conf file</p>
  
  <pre><code>upstream unicorn {
    server unix:/tmp/unicorn.dodeploy.sock fail_timeout=0;
  }
  
  server {
    listen 80 default deferred;
    # server_name example.com;
    root /home/michael/apps/dodeploy/current/public;
  
    location ^~ /assets/ {
      gzip_static on;
      expires max;
      add_header Cache-Control public;
    }
  
    try_files $uri/index.html $uri @unicorn;
    location @unicorn {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://unicorn;
    }
  
    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
  }
  </code></pre>
  
  <p>Update.</p>
  
  <p>this is the method from connection_specification.rb  </p>
  
  <pre><code>     def resolve_hash_connection(spec) # :nodoc:
            spec = spec.symbolize_keys
  
            raise(AdapterNotSpecified, "database configuration does not specify adapter") unless spec.key?(:adapter)
  
            path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter"
            begin
              require path_to_adapter
            rescue Gem::LoadError =&gt; e
              raise Gem::LoadError, "Specified '#{spec[:adapter]}' for database adapter, but the gem is not loaded. Add `$
            rescue LoadError =&gt; e
   raise LoadError, "Could not load '#{path_to_adapter}'. Make sure that the adapter in config/database.yml is$
            end
  
            adapter_method = "#{spec[:adapter]}_connection"
  
            ConnectionSpecification.new(spec, adapter_method)
          end
  </code></pre>