Ruby 3.1.1 failing to build native extensions

Folks,

I need help, I’m new on Fedora and I’m having this error when I run bundle install, using ruby 3.1.1

Using Fedora 38
Rbenv and Ruby 3.1.1
Already installed Postgres using this PostgreSQL — Fedora Developer Portal

The native extention gem requires installing specific C library. It seems the error is in the “pg” gem.
In that case, easy way is to check the upstream project document, then check the RPM package if the gem has the RPM package.

Check the RPM spec file of the rubygem-pg below.
https://src.fedoraproject.org/rpms/rubygem-pg/blob/rawhide/f/rubygem-pg.spec#_28

Maybe you need to install libpq-devel RPM.

$ sudo dnf install libpq-devel

Hey thanks for your reply!
I tried to install and I’m getting this error:


Any suggestion ?

This looks like you have a third-party pgAdmin4 repository enabled on your system, and the packages in that repo are broken.

As Febio said, you have another PostgreSQL client library that you installed from 3rd party repository. If you use the one from the Fedora official repository, removing the one from the 3rd party repository, the command is maybe like this.

$ sudo dnf install --allowerasing libpg-devel

If you want to use the one from the 3rd party, you may install the pg gem separately with the option.

$ gem install pg -- --with-pg-config=<path to pg_config>

Awesome! Thanks guys! I’ll take a look on your suggestions :slight_smile:

I’ve also struggled to get pg hooked up with Rails. I tweaked the Fedora postgres docs a while ago - these steps work for me now together with Rails. Maybe they’ll help! I guess this is why we should be containerizing, but I haven’t gotten round to it yet :slight_smile:

I am not sure if PostgreSQL side cares every client library’s case. But you can send pull-request to edit the document. I think a good practice is, if you faced the compile error for a gem package, then check that the RPM spec file (the recipe file. the RPM package name is “rubygem-foo”) to know how to compile.

If you want to just install Ruby on Rails with Fedora’s Ruby ecosystem, below are the steps. If you want to install Ruby on Rails with the specific Ruby version you like. You need to install it by yourself.