【问题标题】:Trouble installing pg安装 pg 有问题
【发布时间】:2019-10-18 20:19:14
【问题描述】:

我一直在尝试安装一个说要使用的 api

bundle install
rails s

但是当我做捆绑时,我得到了这个错误:

An error occurred while installing pg (0.18.1), and Bundler cannot 
continue. Make sure that `gem install pg -v '0.18.1' --source 'https://rubygems.org/'`succeeds before bundling.

但是当我运行 gem install 命令时,我得到了这个:

错误:安装 pg 时出错: 错误:无法构建 gem 原生扩展。

current directory: /Library/Ruby/Gems/2.3.0/gems/pg-0.18.1/ext /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20191018-63874-el2g8s.rb extconf.rb checking for pg_config... yes Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.  Check the mkmf.log file for more details. You may need configuration options.

并且 mkmf.log 文件说:

ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'

我不确定从哪里开始,因为我已经在网上遵循了大量其他指南,但它们要么不起作用,要么导致我出现新的错误。

【问题讨论】:

  • 你安装了xcode吗?如果没有,你需要。

标签: ruby rubygems bundle homebrew pg


【解决方案1】:

Install brew。这将处理任何依赖项,例如 Xcode 的命令行工具。在终端中运行此命令以安装 brew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

成功安装 brew 后,使用以下命令安装 PostgreSQL:

brew install postgresql

然后重试:

gem install pg -v '0.18.1' --source 'https://rubygems.org/'

请注意,指定的 gem 版本已过期近五年。

【讨论】:

  • 安装自制软件之前不需要先xcode-select --install吗?
  • 前几天全新安装的 Catalina 自动为我完成了这项工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多