0

I'm trying to migrate very old script to ruby 2.7, gem seems to be installed correctly but its throwing out error i am assuming that error is because the script is expecting PG gem version to be 0.9.0 but for some reason on ruby 2.7 this is version is not getting installed and its installing 1.2.3 and dbd-pg calls pg gem so that might be causing this issue.

here is the trace:

Trace: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/dbd-pg-0.3.9/lib/dbd/pg/database.rb:81:in `rescue in initialize'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/dbd-pg-0.3.9/lib/dbd/pg/database.rb:40:in `initialize'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/dbd-pg-0.3.9/lib/dbd/Pg.rb:157:in `new'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/dbd-pg-0.3.9/lib/dbd/Pg.rb:157:in `connect'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/dbi-0.4.4/lib/dbi/handles/driver.rb:33:in `connect'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/dbi-0.4.4/lib/dbi.rb:148:in `connect'
C:/Virtuoz/analytics/setup/setup_analytics_databases.rb:212:in `check_database_exists'
C:/Virtuoz/analytics/setup/setup_analytics_databases.rb:222:in `check_already_set_up'
C:/Virtuoz/analytics/setup/setup_analytics_databases.rb:71:in `set_up_databases'
C:/Virtuoz/analytics/setup/setup_analytics_databases.rb:404:in `block in <main>'
C:/Virtuoz/analytics/setup/setup_analytics_databases.rb:386:in `each'
C:/Virtuoz/analytics/setup/setup_analytics_databases.rb:386:in `<main>'.

PS: I never worked on Ruby so any input is welcome. This is first time we are working with ruby and we are not much familiar with the errors or call stacks.

Thanks in advance

Tom Lord
  • 27,404
  • 4
  • 50
  • 77
  • 1
    `dbd-pg` 0.3.9 was released more than 11 years ago. It would be quite expected if this gem doesn't work with Ruby 2.7 anymore, given that not even Ruby 1.9.2 was released at that time. You may want to either move to a different database adapter (e.g. the [pg](https://github.com/ged/ruby-pg) gem) or use a *much* older Ruby version. – Holger Just Aug 10 '21 at 08:48
  • Issue with native Pg gem is it doesn;t support dynamic initization of object like if i want to execute this statement how can i replace database name dynamically res = conn.exec('CREATE DATABASE $1, db_name ') . How can i replace dbname dynamically? – Akash Chourasia Aug 27 '21 at 07:13

0 Answers0