Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails application using Postgres adapter can't activate pg

In a Rails application, with a bare pg requirement in your Gemfile:

gem 'pg'

You'll get the following error:

Gem::LoadError can't activate pg (~> 0.18), already activated pg-1.0.0. Make sure all dependencies are added to Gemfile.
like image 675
Abe Voelker Avatar asked Jan 11 '18 06:01

Abe Voelker


1 Answers

The pg gem recently released version 1.0.0 which is not yet compatible with Rails.

If you're on Rails 5, change your Gemfile's pg requirement to the following1:

gem 'pg', '~> 0.18'

or on Rails < 5, this:

gem 'pg', '~> 0.11'

And then run

bundle update pg


1 Bundler will effectively do the exact same thing with either line, but this way you'll match the Rails source code's runtime check exactly, as well as the version emitted by rails new's Gemfile generator.
like image 179
Abe Voelker Avatar answered Nov 08 '22 00:11

Abe Voelker