为数据库适配器指定了"postgresql",但未加载 gem



我正在尝试rails db:create为我的 rails 5.0.0.1 应用程序创建一个数据库,但收到以下错误:

Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

关键是我的 Gemfile 中有一个gem 'pg',它由bundle update1.0.0 更新到 1.0.0 版,在bundle install之后启动:

$ gem list
...
pg (1.0.0, 0.20.0)

我不知道为什么 rails 无法识别已安装的 pg gem 并且无法为我的应用程序创建数据库。

PG 版本 1.0.0 在 Rails 5.1.5 及更高版本上工作正常。 查看此 github 帖子