Question

I have tried several ways to deploy to my server using Capistrano v3 but its has failed with the following error; I have tried precompiling locally but it has failed.

DEBUG [4ec78ee3] Command: cd /var/www/html/webapp/releases/20140101221937 && bundle exec rake assets:precompile RAILS_ENV=production
DEBUG [4ec78ee3]    /usr/local/bin/ruby /var/www/html/webapp/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
DEBUG [4ec78ee3]    rake aborted!
DEBUG [4ec78ee3]    undefined method `fetch' for false:FalseClass

My deploy file looks like this below;

SSHKit.config.command_map[:rake] = "bundle exec rake"

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
       execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
       within release_path do
         execute :rake, 'cache:clear'
       end
    end
  end

  after :finishing, 'deploy:cleanup'

end

Here is a detailed trace;

INFO [4ec78ee3] Running bundle exec rake assets:precompile RAILS_ENV=production on 208.68.39.56
DEBUG [4ec78ee3] Command: cd /var/www/html/webapp/releases/20140101221937 && bundle exec rake assets:precompile RAILS_ENV=production
DEBUG [4ec78ee3]    /usr/local/bin/ruby /var/www/html/webapp/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
DEBUG [4ec78ee3]    rake aborted!
DEBUG [4ec78ee3]    undefined method `fetch' for false:FalseClass
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:35:in `resolve_string_connection'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `each'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
DEBUG [4ec78ee3]    /var/www/html/webapp/releases/20140101221937/config/environment.rb:5:in `<top (required)>'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
DEBUG [4ec78ee3]    Tasks: TOP => environment
DEBUG [4ec78ee3]    (See full trace by running task with --trace)
DEBUG [4ec78ee3]    rake aborted!
DEBUG [4ec78ee3]    Command failed with status (1): [/usr/local/bin/ruby /var/www/html/webapp/s...]
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
DEBUG [4ec78ee3]    Tasks: TOP => assets:precompile
DEBUG [4ec78ee3]    (See full trace by running task with --trace)

I have run cap production deploy:compile_assets

and got this; cap aborted!

if test ! -d /var/www/html/webapp/current; then echo "Directory does not exist '/var/www/html/webapp/current'" 1>&2; false; fi stdout: Nothing written
if test ! -d /var/www/html/webapp/current; then echo "Directory does not exist '/var/www/html/webapp/current'" 1>&2; false; fi stderr: Nothing written

Remember, its still an empty file.

Was it helpful?

Solution

This is not a complete answer, but is the first step in troubleshooting.

First, go to the server and run the exact same command that Capistrano is running to make sure you can reproduce the exact same error. This puts Capistrano out of the picture and now the bug becomes just something about Rails and your configuration of it.

Here is the line that is raising the error:

https://github.com/rails/rails/blob/v3.2.13/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb#L35

The error message tells us that configurations is false, but the code is expecting it to be some object that responds to fetch (probably a hash). The problem is that the @configurations instance variable inside this ActiveRecord::Base::ConnectionSpecification::Resolver got set to false erroneously. Do you know why that might be happening? I would check all the configuration files that have anything to do with the database connection and make sure they look OK.

If that does not help, the next step is to find out why that variable is getting set to false. Well, if we look two lines lower in the stack trace, we can see how this Resolver object got created and used:

https://github.com/rails/rails/blob/v3.2.13/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb#L129-130

That method is just calling ActiveRecord::Base.configurations and passing it to the Resolver object. So now the question becomes how did ActiveRecord::Base.configurations get set to false?

Edit 1:

Here is the documentation and code for ActiveRecord::Base.configurations:

https://github.com/rails/rails/blob/v3.2.13/activerecord/lib/active_record/base.rb#L341-369

It sounds like ActiveRecord::Base.configurations is supposed to come from your database.yml file. You should go to your server and look carefully at your database.yml file and see if it might somehow be read as false. You should post that file here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top