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?
EDIT: the segfault described in the original question was caused by the PG client libraries, not the pg gem, so this answer doesn’t help with it. See the above answer instead. However, pinning older versions of a gem is always a reasonable troubleshooting step when you start to suddenly see failures you can’t otherwise debug in a process known as [bisecting](https://en.m.wikipedia.org/wiki/Bisection_(software_engineering).
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:
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.