【问题标题】:An error occurred while installing pg (1.2.3), and Bundler cannot continue安装 pg (1.2.3) 时出错,Bundler 无法继续
【发布时间】:2021-05-13 07:59:18
【问题描述】:

我已经看过一百万次了,但是这次我通常的修复和 stackoverflow 建议都不起作用了。

当我运行 bundle install 时,它在 pg 处失败:

An error occurred while installing pg (1.2.3), and Bundler cannot
continue.

过去,我通过先运行 gem install bundler 再运行 bundle install 来解决此问题。这一次,运气不好。有什么建议吗?

【问题讨论】:

标签: ruby-on-rails ruby bundler


【解决方案1】:

遇到同样的问题,我通过首先安装 brew install postgresql 并再次运行 bundle install 解决了这个问题

【讨论】:

    【解决方案2】:

    值得一提的是,您需要在要安装 gem 的任何机器上安装 Postgres。

    这对某些人来说可能很明显,但对其他人来说却不是。

    验证实际问题是机器上缺少Postgres,错误应该和这个有点类似:

    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.
    

    【讨论】:

      【解决方案3】:

      当然,在我发布此内容的那一刻,我找到了解决另一个 stackoverflow 问题的方法。

      这成功了:

      gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
      

      【讨论】:

      • 谢谢,这很重要 - 在 Mac 上安装 Postgres 有两种主要方法,一种是通过 Homebrew(大多数答案都与此相关),另一种是使用 Postgres.app,此答案针对.感谢您添加沙粒并帮助像我这样拥有后者的人。
      猜你喜欢
      • 2014-01-12
      • 2018-04-05
      • 2020-05-07
      • 2017-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多