Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

"database does not exist" after updating to 1.3.3 #499

Closed
rdubya opened this Issue Nov 18, 2013 · 2 comments

Comments

Projects
None yet
2 participants
Collaborator

rdubya commented Nov 18, 2013

I just updated to 1.3.3 from 1.3.2 and started receiving an error that the database does not exist. I reverted back to 1.3.2 and it operates correctly.

I did a little testing and it appears that the reason it is failing is because ENV['PGHOST'] is getting defaulted to '/tmp' somewhere. I was able to fix the issue by configuring the host in my database.yml file to use localhost:

test:
  adapter: postgresql
  database: cms_test
  host: localhost

After digging through it, this may be too specific of an issue to warrant a fix, but I wanted to at least get it documented in case anybody else runs in to it.

Here is the error that I get when trying to run my rspec tests:

ActiveRecord::JDBCError: The driver encountered an unknown error: org.postgresql.util.PSQLException: FATAL: database "tmp:5432/cms_test" does not exist
               initialize at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-jdbc-adapter-1.3.3/lib/arjdbc/jdbc/connection.rb:23
               initialize at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-jdbc-adapter-1.3.3/lib/arjdbc/jdbc/adapter.rb:68
               initialize at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-jdbc-adapter-1.3.3/lib/arjdbc/postgresql/adapter.rb:1265
          jdbc_connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-jdbc-adapter-1.3.3/lib/arjdbc/jdbc/connection_methods.rb:12
    postgresql_connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-jdbc-adapter-1.3.3/lib/arjdbc/postgresql/connection_methods.rb:41
           new_connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:440
  checkout_new_connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:450
       acquire_connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:421
                 checkout at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:356
          mon_synchronize at /Users/rdubya/.rvm/rubies/jruby-1.7.6/lib/ruby/1.9/monitor.rb:211
                 checkout at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:355
               connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265
          mon_synchronize at /Users/rdubya/.rvm/rubies/jruby-1.7.6/lib/ruby/1.9/monitor.rb:211
               connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:264
      retrieve_connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:546
      retrieve_connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:79
               connection at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:53
          current_version at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/migration.rb:792
         needs_migration? at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/migration.rb:800
           check_pending! at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/activerecord-4.0.0/lib/active_record/migration.rb:379
                   (root) at /Users/rdubya/RubymineProjects/finalsite_CMS/spec/spec_helper.rb:90
                 each_run at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/spork-1.0.0rc4/lib/spork.rb:37
                   (root) at /Users/rdubya/RubymineProjects/finalsite_CMS/spec/spec_helper.rb:85
                  require at org/jruby/RubyKernel.java:1082
                   (root) at /Users/rdubya/RubymineProjects/finalsite_CMS/spec/models/element_link_spec.rb:1
                     load at org/jruby/RubyKernel.java:1101
                   (root) at /Users/rdubya/RubymineProjects/finalsite_CMS/spec/models/element_link_spec.rb:1
                     each at org/jruby/RubyArray.java:1613
                   (root) at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:1
          load_spec_files at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896
          load_spec_files at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896
                      run at /Users/rdubya/.rvm/gems/jruby-1.7.6/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:22

Environment:
rails: 4.0.0
jruby: 1.7.6
java: 1.7.0_13
activerecord-jdbc-adapter: 1.3.3
activerecord-jdbcpostgresql-adapter: 1.3.3
postgres: 9.2.4 (running inside Postgres.app from Heroku)
OS: Mac 10.9

Thanks!

(Sorry if this is a duplicate, the original submission took me to a 404 page and I couldn't find it anywhere so I'm submitting again.)

Owner

kares commented Nov 18, 2013

Thank you Rob, this should than occur on MRI + pg as well ... any guess who's setting the ENV['PGHOST'] ?

Collaborator

rdubya commented Nov 18, 2013

Sorry, just did a little bit of research on the ENV variable. It looks like PGHOST is set in my shell environment for some reason and it is picking it up from there. Thanks for taking a look at the ticket.

@kares kares closed this Nov 18, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment