【发布时间】:2018-08-19 20:28:56
【问题描述】:
我将数据库的 pg gem 更新到 1.0.0 版本,现在遇到了问题。我正在尝试恢复到以前的版本,但仍然出现错误。还有其他人有同样的问题吗?
宝石文件
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.21.0'
运行rake db:migrate时出错
dyld: lazy symbol binding failed: Symbol not found: _rb_fd_init
Referenced from: /Users/topher/.rvm/gems/ruby-2.5.0/gems/pg-0.21.0/lib/pg_ext.bundle
Expected in: flat namespace
我运行rails s时没有错误
当我将 Gemfile 更改为 pg gem 的最新版本时,我收到以下错误:
宝石文件
# Use postgresql as the database for Active Record
gem 'pg', '~> 1.0.0'
运行rake db:migrate时出错
rake aborted!
Gem::LoadError: 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).
运行rails s时出错
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). (Gem::LoadError)
还有其他人遇到这个问题并有解决办法吗?
【问题讨论】:
-
我当然是在更改 Gemfile 后运行
bundle install。 -
你在 OS X 上吗?如果是,是哪个版本?我问这个是因为,也许,您可以通过使用
xcode-select --install更新/选择正确的 XCode 来解决它 -
我在 OS X. 10.13.3 上。 XCode 是版本 9.2 (9C40b)
-
在
Gemfile中更改版本后尝试bundle update pg。打赌你有旧版本Gemfile.lock -
@MartinZinovsky,
bundle update pg带来了这个结果:Bundler attempted to update pg but its version stayed the same。此外,Gemfile.lock确实显示了pg (~> 1.0.0)。
标签: ruby-on-rails ruby postgresql pg