evilmartians / chronicles-gql-martian-library

71 stars 36 forks source link

./bin/setup could not connect database when run with Docker #6

Closed smoothdvd closed 5 years ago

smoothdvd commented 5 years ago
could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Couldn't create 'rails-docker_test' database. Please check your configuration.
rails aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `initialize'
/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `new'
/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `connect'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:692:in `connect'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `new'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `postgresql_connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:811:in `new_connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:855:in `checkout_new_connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:834:in `try_to_checkout_new_connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:795:in `acquire_connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:523:in `checkout'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1014:in `retrieve_connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:90:in `connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection'
/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/postgresql_database_tasks.rb:21:in `create'
/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:119:in `create'
/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current'
/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration'
/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:313:in `each'
/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration'
/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:138:in `create_current'
/bundle/gems/activerecord-5.2.3/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <main>'
/bundle/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/bundle/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/bundle/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/bundle/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>'
/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/app/bin/rails:9:in `<top (required)>'
/bundle/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/bundle/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/bundle/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/bundle/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/bundle/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/bundle/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/bundle/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/app/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:setup => db:schema:load_if_ruby => db:create
(See full trace by running task with --trace)

== Command ["bin/rails db:setup"] failed ==
DmitryTsepelev commented 5 years ago

Hi @smoothdvd ! You're trying to run docker-compose run runner ./bin/setup, right?

smoothdvd commented 5 years ago

@DmitryTsepelev Yes. Do I need edit config/database.yml?

DmitryTsepelev commented 5 years ago

I haven't tried to run it in Docker before, so that was a "clear" attempt: I've pulled master and ran

$ docker-compose build
$ docker-compose run runner yarn install
$ docker-compose run runner ./bin/setup

Everything was fine. Did two previous steps work successfully for you?

smoothdvd commented 5 years ago

@DmitryTsepelev I found that's Rails 5.x's issue. Under Rails 5.2.3, I need set database_url explicit to avoid the error.