[英]Cannot install pg gem in Mavericks with Postgres.app
我正在嘗試在本地計算機上安裝pg gem與Postgres.app一起使用。 我在跑小牛。
Postgres.app已安裝並運行良好,但是我無法運行該gem。 我已經完成以下工作:
一切都沒有成功。 這是我收到的特定錯誤消息:
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上,這是我要做的事情:
現在運行(希望是一個經過驗證的命令):
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
這對我有用:
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.