运行rake任务bundle exec rake db:setup
时出现错误,因为我无法连接到数据库。但是,堆栈跟踪永远不会显示我的应用程序或rails rake任务代码的来源。这是吐出的堆栈跟踪。
导致此堆栈跟踪的原因是什么?
更新
我知道问题的原因是无法访问数据库。我的问题:为什么我不能在stacktrace中看到哪些代码试图访问数据库?
The driver encountered an unknown error: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/connection.rb:23:in `initialize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/adapter.rb:68:in `initialize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/postgresql/adapter.rb:1275:in `initialize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/connection_methods.rb:12:in `jdbc_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/postgresql/connection_methods.rb:45:in `postgresql_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `checkout'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:53:in `connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:73:in `create'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:87:in `create_current'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/tasks/databases4.rake:12:in `each_current_configuration'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/tasks/databases4.rake:11:in `each_current_configuration'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:86:in `create_current'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:20:in `(root)'
org/jruby/RubyProc.java:271:in `call'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:236:in `execute'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:175:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:197:in `invoke_prerequisites'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:195:in `invoke_prerequisites'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:174:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:197:in `invoke_prerequisites'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:195:in `invoke_prerequisites'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:174:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:106:in `top_level'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:106:in `top_level'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:78:in `run'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/bin/rake:33:in `(root)'
org/jruby/RubyKernel.java:1099:in `load'
/Users/john/.rbenv/versions/jruby-1.7.9/bin/rake:23:in `(root)'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"app_snapshot", "pool"=>500, "username"=>"john", "password"=>nil}
The driver encountered an unknown error: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/connection.rb:23:in `initialize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/adapter.rb:68:in `initialize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/postgresql/adapter.rb:1275:in `initialize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/connection_methods.rb:12:in `jdbc_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/postgresql/connection_methods.rb:45:in `postgresql_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `checkout'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:53:in `connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:73:in `create'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:87:in `create_current'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/tasks/databases4.rake:12:in `each_current_configuration'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/tasks/databases4.rake:11:in `each_current_configuration'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:86:in `create_current'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:20:in `(root)'
org/jruby/RubyProc.java:271:in `call'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:236:in `execute'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:175:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:197:in `invoke_prerequisites'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:195:in `invoke_prerequisites'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:174:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:197:in `invoke_prerequisites'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:195:in `invoke_prerequisites'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:174:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:106:in `top_level'
org/jruby/RubyArray.java:1613:in `each'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:106:in `top_level'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:78:in `run'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/rake-10.1.1/bin/rake:33:in `(root)'
org/jruby/RubyKernel.java:1099:in `load'
/Users/john/.rbenv/versions/jruby-1.7.9/bin/rake:23:in `(root)'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"app_test", "pool"=>5, "username"=>"john", "password"=>nil}
答案 0 :(得分:0)
您正在看到调用它的代码。
bundle exec rake db:setup
不是您创建的内容,因此不太可能引用您的代码。
代码由/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/connection.rb:23:in
initialize'运行,由下面一行运行,等等。
我认为这些界限与您将变得有趣和相关的一样接近:
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/postgresql_database_tasks.rb:8:in 'connection'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/postgresql_database_tasks.rb:17:in 'create'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:73:in 'create'
/Users/john/.rbenv/versions/jruby-1.7.9/lib/ruby/gems/shared/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:87:in 'create_current'