使用 Postgres 适配器的 Rails 应用程序无法激活 pg [英] Rails application using Postgres adapter can't activate pg

查看:21
本文介绍了使用 Postgres 适配器的 Rails 应用程序无法激活 pg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Rails 应用程序中,您的 Gemfile 中只有一个 pg 需求:

gem 'pg'

您将收到以下错误:

Gem::LoadError 无法激活 pg (~> 0.18),已经激活了 pg-1.0.0.确保所有依赖项都添加到 Gemfile.

解决方案

pg gem 最近发布的版本 1.0.0 尚不与 Rails 兼容.

如果您使用的是 Rails 5,请将 Gemfile 的 pg 要求更改为以下1:

gem 'pg', '~>0.18'

或在 Rails 上

5、这个:

gem 'pg', '~>0.11'

然后运行

捆绑更新pg

<小时>1 Bundler 将有效地对任一行执行完全相同的操作,但这样您将匹配 Rails 源代码的 运行时检查,以及Gfile生成器>发布的新版本rails.

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.

解决方案

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.

这篇关于使用 Postgres 适配器的 Rails 应用程序无法激活 pg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆