5

I have

Ruby 3.0.4
Rails 6.1.7
pg 1.4.5
postgresql 14.6

Here is my database.yml file

development:
adapter: postgresql
encoding: utf8
database: olio_development
username: postgres
password: password
pool: 5 
host: 127.0.0.1
port: 5432
gssencmode: disable

When I run rake db:create I am getting the following segmentatin fault

/home/usr/.rvm/gems/ruby-3.0.4/gems/pg-1.4.5/lib/pg/connection.rb:626: [BUG] Segmentation fault at 0x00007fd79729a140

ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]

-- Control frame information -----------------------------------------------
 c:0050 p:---- s:0275 e:000274 CFUNC  :connect_poll
c:0049 p:0543 s:0271 e:000270 METHOD /home/suganya/.rvm/gems/ruby-3.0.4/gems/pg-1.4.5/lib/pg/connection.rb:626

The connection fails.

I have verified postgres is running and is on host 127.0.0.1 and post 5432.

Please help me how to resolve this segmentation fault?

Suganya Selvarajan
  • 962
  • 1
  • 11
  • 33

2 Answers2

7

I came across this question while searching for a solution to a similar issue. So will post the fix which worked for me, maybe it will help someone else.

My environment:

Ruby 3.2.2
Rails 7.0.4.3
pg 1.4.5
postgresql 14.9

Adding the following line to .zshrc (and restarting the terminal) fixed the problem for me:

export PGGSSENCMODE="disable"
Anton Tsapov
  • 1,181
  • 9
  • 10
5

I'm seeing a GitHub issue for the pg gem (https://github.com/ged/ruby-pg/issues/493) that matches your problem, so it might be a bug with pg v1.4.5. I would try pinning it to an older version:

gem 'pg', '1.4.4'

And work your way backwards if that still has issues. You can also add your information to the GitHub issue linked above to help the maintainers resolve the issue.

Robert Nubel
  • 7,104
  • 1
  • 18
  • 30