簡體   English   中英

無法使用Postgres.app在小牛中安裝pg gem

[英]Cannot install pg gem in Mavericks with Postgres.app

我正在嘗試在本地計算機上安裝pg gem與Postgres.app一起使用。 我在跑小牛。

Postgres.app已安裝並運行良好,但是我無法運行該gem。 我已經完成以下工作:

  1. 使用了來自Postgres.app文檔的命令'env ARCHFLAGS =“-arch x86_64” gem install pg---with-pg-config = / Applications / Postgres.app / Contents / MacOS / bin / pg_config
  2. 更新了Homebrew並安裝了Apple GCC 4.2
  3. 安裝了Xcode開發人員工具
  4. 更新了我的$ PATH以同時引用Postgres.app bin和lib目錄

一切都沒有成功。 這是我收到的特定錯誤消息:

Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config'
This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/

我會很感激您能提供的任何幫助。 謝謝!

您可能使用--with-pg-config路徑錯誤,請檢查它是否確實存在。

您可以使用以下命令找到pg_config的正確路徑:

find /Applications -name pg_config

在最新的Postgres.app版本中,路徑為:

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

就我而言(運行Postgres.app v9.3.4.2),它似乎僅在附加環境體系結構標志時才起作用:

env ARCHFLAGS="-arch x86_64" gem install pg -- \
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config 

在全新的Mac上,這是我要做的事情:

  1. 從應用商店安裝Xcode工具
  2. 打開Xcode工具並接受許可
  3. 現在運行(希望是一個經過驗證的命令):

    version=$(ls /Applications/Postgres.app/Contents/Versions/ | tail -1) gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/$version/bin/pg_config .

如果遇到問題,可以通過檢查mkmf.log中的實際錯誤(通過運行(如果使用rvm)可以找到)發現一些故障:

cd ~/.rvm ; find . -name mkmf.log | grep pg

我能夠使用此命令安裝pg

    gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config

我通過跑步找到了自己的路

    sudo find / -name "pg_config"

並且我成功安裝了pg-0.17.1

將postgress bin目錄添加到路徑也可以解決問題。 像這樣將垃圾箱添加到拍拍中 對於最新安裝的產品,最新的符號鏈接可確保此路徑在以后的版本升級中應該是“穩定的”。

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin

要解決此問題,我在終端窗口中使用以下方法使用自制軟件安裝了postgres:

brew install postgres

自制酒可以在這里找到

http://brew.sh

這對我有用:

gem install pg -- --with-pg-config=`which pg_config`

供以后參考,因為我們很多人都在發布新版本號的新路徑:

目前,我在/Applications/Postgres.app/Contents/Versions/看到一個名為latest的符號鏈接。

您應該能夠做到:

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

忘記版本號。 這可能不適用於每個(較舊的)版本,但我本人正在尋找可以保存和重復使用的代碼段。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM