Rails pg gem Incompatible library version

Try:

$ gem install pg
$ gem pristine --all

Added by Vivi Poit on September 21, 2022:

This answer has been around for a while. It has just helped me, as well. However, it's always good to provide folks with some explanations as to why something works, so here are two resources I looked into before executing the commands:

3 Quick Gem Tricks by Justin Weiss

bundle pristine in Bundler Docs


It looks as if you might be suffering from this bug: https://bitbucket.org/ged/ruby-pg/issues/229/pg_exit-improperly-linked-when-using-rvm

The libruby version should be different, apparently.

However: I have the same error message, and my libruby is correct, so I think that there might be more going on...


I get the same error when I call in console rails c. Calling bundle exec rails c removed that error.


I faced with this problem. I had ruby 2.2.1. I upgraded ruby to 2.3.3 and after it worked. Try this instruction:

rvm install ruby-2.3.3
rvm gemset empty
gem install bundler
bundle install