【问题标题】:Rails 5: trying to bundle install end getting error with pg gemRails 5:尝试使用 pg gem 捆绑安装端出现错误
【发布时间】:2018-01-14 17:26:35
【问题描述】:

我正在使用 rails 5 和 Rubymine,当我尝试使用 bundler install 时,出现以下错误:

compiling pg_type_map_all_strings.c
compiling pg_type_map_by_class.c
compiling pg_type_map_by_column.c
compiling pg_type_map_by_mri_type.c
compiling pg_type_map_by_oid.c
compiling pg_type_map_in_ruby.c
compiling util.c
linking shared-object pg_ext.bundle
ld: file not found: dynamic_lookup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pg_ext.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/theopap/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pg-1.0.0 for
inspection.
Results logged to
/Users/theopap/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_6
4-darwin-16/2.4.0-static/pg-1.0.0/gem_make.out

An error occurred while installing pg (1.0.0), and Bundler cannot continue.
Make sure that `gem install pg -v '1.0.0'` succeeds before bundling.

In Gemfile:
  pg

我尝试卸载pg gem 并根据@Neeraj Gupta 的answer 安装新的,但在bundler install 之后仍然出现此错误。

任何想法为什么会发生这种情况?

【问题讨论】:

  • 你安装了 PostgreSQL 吗?
  • 感谢@Leo Correa 的回复。是的,我愿意。 postgres (PostgreSQL) 10.1 来自终端与postgres -V
  • 我忘了说我正在使用 Rubymine

标签: ruby-on-rails postgresql


【解决方案1】:

您可能缺少 Postgres 开发标头/库 (libpq-dev)。

您是如何安装 Postgres 的?

如果你在 MacOS 上,你可以通过 Homebrew 安装 Postgres,它会为你包含必要的开发头文件:

brew install postgresql

【讨论】:

  • 感谢@Jeffrey Harrington 的回复...我已经安装了postgresql 和brew install postgresql。但尝试重新安装它,我得到了这个:Warning: postgresql 10.1 is already installed
  • @Theopap 有趣。我刚刚重新创建了您的问题(High Sierra、Ruby 2.4、Rails 5、PG 10.1),通过从 Homebrew 安装 PG 解决了问题。也许检查您的 Homebrew 安装目录 (/usr/local/bin) 是否在您的 $PATH 中正确使用export PATH="/usr/local/bin:$PATH"
  • 感谢@Jeffrey Harrington 的回复,我解决了这个问题,我必须更新 ruby​​mine 然后bundler install。我不知道为什么,但它是这样工作的。
猜你喜欢
  • 1970-01-01
  • 2018-10-01
  • 2021-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多