Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActiveRecord::NoDatabaseError if current user does not have a postgres role #56

Closed
rojoko opened this issue Jan 5, 2015 · 4 comments
Closed
Labels

Comments

@rojoko
Copy link
Contributor

rojoko commented Jan 5, 2015

When I try to run ferry in development I end up with an ActiveRecord::NoDatabaseError (see stack trace below). I solved the issue in a fork and will create a pull request for it. It seems like the problem occurs because ferry tries to use the system user name to access the postgreSQL server.

$ ferry --to_csv development items

operating with postgresql
/home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:898:in `rescue in connect': FATAL:  role "roland" does not exist (ActiveRecord::NoDatabaseError)
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/connection_handling.rb:87:in `connection'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/ferry-1.0.1/lib/ferry/exporter.rb:11:in `to_csv'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/ferry-1.0.1/bin/ferry:12:in `block (2 levels) in <top (required)>'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/optparse.rb:1359:in `call'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/optparse.rb:1359:in `block in parse_in_order'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/optparse.rb:1346:in `catch'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/optparse.rb:1346:in `parse_in_order'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/optparse.rb:1340:in `order!'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/optparse.rb:1432:in `permute!'
  from /home/roland/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/optparse.rb:1454:in `parse!'
  from /home/roland/.rvm/gems/ruby-2.1.2/gems/ferry-1.0.1/bin/ferry:50:in `<top (required)>'
  from /home/roland/.rvm/gems/ruby-2.1.2/bin/ferry:23:in `load'
  from /home/roland/.rvm/gems/ruby-2.1.2/bin/ferry:23:in `<main>'
  from /home/roland/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
  from /home/roland/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

Rspec also fails with:

$ rspec spec/tests/utilities_tests.rb
Failures:

  1) utility functions #db_connect #postgresql
     Failure/Error: expect(ActiveRecord::Base.connection.adapter_name).to eql('PostgreSQL')
     ActiveRecord::NoDatabaseError:
       FATAL:  role "roland" does not exist
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/postgresql_adapter.rb:898:in `rescue in connect'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
     # /home/roland/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.8/lib/active_record/connection_handling.rb:87:in `connection'
     # ./tests/utilities_tests.rb:15:in `block (3 levels) in <top (required)>'
@anthonycorletti
Copy link
Contributor

@rojoko we had to revert #57 because it broke a couple tests. See #79 for the failures.

Did you run into these failures when you tested locally?

@anthonycorletti
Copy link
Contributor

It seems I just had to change ownership of some tables for most of the tests to pass locally.

But I'm still seeing one failure ...

Failures:

  1) utility functions #db_connect #postgresql fails if system user name is not role in PostgreSQL
     Failure/Error: expect{ActiveRecord::Base.connection.adapter_name}.to raise_error
       expected Exception but nothing was raised
     # ./tests/utilities_tests.rb:20:in `block (3 levels) in <top (required)>'

@anthonycorletti
Copy link
Contributor

resolved in #81

@rojoko
Copy link
Contributor Author

rojoko commented Jan 28, 2015

@anthcor great that you fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants