Skip to content

Conversation

@larskanis
Copy link
Collaborator

If the 3.4/pg_ext.so doesn't load, the specific error message is overwritten by the subsequent LoadError of pg_ext.so. This is bad since this can hide valuable information about the load error, like a missing dependency. One such mussing dependency can be the required GLIBC version.

This patch adds a more descriptive error message containing both attempts to load the C extension. And it adds an additional help text for the special case of a GLIBC load error.

The old error:

cannot load such file -- pg_ext (LoadError)

The new error:

pg's C extension failed to load: (LoadError)
  /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /root/.rubies/ruby-3.2.9/lib/ruby/gems/3.2.0/gems/pg-1.6.1-x86_64-linux/lib/3.2/pg_ext.so) - /root/.rubies/ruby-3.2.9/lib/ruby/gems/3.2.0/gems/pg-1.6.1-x86_64-linux/lib/3.2/pg_ext.so
  cannot load such file -- pg_ext

The GLIBC version of this system seems too old. Please use the source version of pg:
    gem uninstall pg --all
    gem install pg --platform ruby
or in your Gemfile:
    gem "pg", force_ruby_platform: true
See also: https://github.com/ged/ruby-pg/blob/master/README.md#source-gem

Changing from tabs to spaces for better message formatting.

Relates to #661

@larskanis larskanis force-pushed the better-error branch 2 times, most recently from 471ffea to b1d2919 Compare August 7, 2025 13:22
If the `3.4/pg_ext.so` doesn't load, the specific error message is overwritten by the subsequent LoadError of `pg_ext.so`.
This is bad since this can hide valuable information about the load error, like a missing dependency.
One such mussing dependency can be the required GLIBC version.

This patch adds a more descriptive error message containing both attempts to load the C extension.
And it adds an additional help text for the special case of a GLIBC load error.

The old error:
```
cannot load such file -- pg_ext (LoadError)
```

The new error:
```
pg's C extension failed to load: (LoadError)
  /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /root/.rubies/ruby-3.2.9/lib/ruby/gems/3.2.0/gems/pg-1.6.1-x86_64-linux/lib/3.2/pg_ext.so) - /root/.rubies/ruby-3.2.9/lib/ruby/gems/3.2.0/gems/pg-1.6.1-x86_64-linux/lib/3.2/pg_ext.so
  cannot load such file -- pg_ext

The GLIBC version of this system seems too old. Please use the source version of pg:
    gem uninstall pg --all
    gem install pg --platform ruby
or in your Gemfile:
    gem "pg", force_ruby_platform: true
See also: https://github.com/ged/ruby-pg/blob/master/README.md#source-gem
```

Changing from tabs to spaces for better message formatting.

Relates to ged#661
@larskanis larskanis merged commit 2d950d4 into ged:master Aug 28, 2025
50 of 57 checks passed
@larskanis larskanis deleted the better-error branch August 28, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants