简体   繁体   English

安装pg gem而不安装postgres macOS

[英]Install pg gem without installing postgres macOS

This is an easy problem that can be fixed if you don't mind install Postgres database using Homebrew. 如果您不介意使用Homebrew安装Postgres数据库,这是一个容易解决的问题。

But my use case, Postgres database is run by docker in the development machine and exposing port into into host. 但是我的用例,Postgres数据库由开发机器中的docker运行,并将端口暴露到主机中。 Then I need to install gem pg to development machine which require pg_config . 然后我需要将gem pg安装到需要pg_config开发机器上。 As you may know, this is operation will fail since it's not presented. 您可能知道,这是操作将失败,因为它没有呈现。

This is a bit frustrating since the quick fix is that I just have to install Postgres via Homebrew first then gem install pg to solve this. 这有点令人沮丧,因为快速解决方案是我只需要先通过Homebrew安装Postgres然后gem install pg来解决这个问题。

But it could be better if postgres isn't required for the installation, since I already have it via docker and install it seems to be a bit of duplication. 但如果安装不需要postgres可能会更好,因为我已经通过docker安装它并且安装它似乎有点重复。

What I would like to ask is that do we have an alternatives way for this to work without the need to install postgres ? 我想问的是,我们是否有一种替代方式可以在不需要安装postgres的情况下工作?

I'd searched about libpq , which available in linux but it seems it's not available for macOS. 我搜索了libpq ,它在linux中可用,但似乎它不适用于macOS。

Got the answer from my colleague. 得到了我同事的答案。 Install libpq then install pg gem with this command 安装libpq然后使用此命令安装pg gem

gem install pg -v '0.20.0' -- --with-opt-dir="/usr/local/opt/libpq"

solve the issue 解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM