簡體   English   中英

pg寶石'0.14.0'在Mountain Lion上失敗

[英]pg gem '0.14.0' on Mountain Lion fails

我剛剛從OS X Lion升級到OS X Mountain Lion。 我的rails環境大部分保持不變。

我要做的唯一使步驟恢復到良好狀態的步驟是:-安裝XCode 4.4-安裝XCode 4.4命令行工具-安裝gcc-4.2

所以一切順利。

這就是問題所在,當我運行捆綁安裝時,幾乎所有我的gem都正確安裝,除了我需要的最重要的之一-postgresql gem'pg'。

特別是對於高於0.12.2的版本,它將失敗。

我正在使用ruby 1.9.3p125。

我可以成功獲取0.12.2 pg的寶石和以下版本,但是它們給我帶來分割錯誤(我猜是因為我使用的紅寶石版本)。

因此,這使我相信它是特定於pg gem的,而不是我的整體環境看到其他gem可以正常安裝。

我還嘗試重新安裝Postgresql,以確保我的postgres環境正常並且在那方面看起來不錯。

是否有人能夠安裝“ pg” gem版本0.13.0或更高版本(最好是0.14.X)?

這是我的堆棧跟蹤:

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

    /Users/caseyli/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/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... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... no
checking for PGRES_COPY_BOTH in libpq-fe.h... no
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile

make
compiling pg.c
pg.c: In function ‘pg_s_library_version’:
pg.c:273: warning: implicit declaration of function ‘PQlibVersion’
pg.c: In function ‘Init_pg_ext’:
pg.c:384: error: ‘PQPING_OK’ undeclared (first use in this function)
pg.c:384: error: (Each undeclared identifier is reported only once
pg.c:384: error: for each function it appears in.)
pg.c:386: error: ‘PQPING_REJECT’ undeclared (first use in this function)
pg.c:388: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function)
pg.c:390: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function)
make: *** [pg.o] Error 1


Gem files will remain installed in /Users/caseyli/.rvm/gems/ruby-1.9.3-        p125@elliottfarmequipment/gems/pg-0.14.0 for inspection.

迪福的評論得到了! 這是我安裝PostgreSQL的方式。

我使用的是PostgreSQL一鍵式安裝程序,我猜它無法為Mountain Lion正確設置libpq。

另一方面,自制軟件將為操作系統正確構建它。

通過自制軟件安裝postgres之后

brew install postgresql

我能夠安裝我的寶石沒有問題。

謝謝大家!

問題是pg_config的位置。 如果您使用一鍵式安裝程序,則它位於/Library/PostgreSQL/9.2/bin/pg_config中,因此可以很好地構建您的gem:

env ARCHFLAGS =“-arch x86_64” gem install pg---with-pg-config = / Library / PostgreSQL / 9.2 / bin / pg_config

我有完全相同的問題; 與您發布的堆棧跟蹤相同。

帶有自制軟件的MRI 1.9.3-p286 / OS X 10.8.2 / Postgres 9.0.4。

我通過簡單地解決它:

$ brew update
$ brew upgrade postgresql
$ bundle

希望它對其他人有用。

重新安裝紅寶石修復了我升級到Mountain Lion后遇到的類似問題

rvm reinstall 1.9.3

注意:也可以運行以下命令,因為默認版本似乎已重置

rvm --default 1.9.3

作為參考,我在下面發布了我看到的錯誤

gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with pg=/usr/local/Cellar/postgresql/9.1.4/bin
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***

Mac隨附了過時的預建PostgreSQL客戶端安裝,並且隨附的pg_config文件與任何新的PostgreSQL服務器和客戶端安裝沖突。

使用完全限定的文件名pg_config安裝ruby gem會覆蓋pg_config的默認已知位置,並且安裝成功。

通過EnterpriseDB一鍵安裝程序pg_config的當前位置:/ Library / PostgreSQL / bin / pg_config

這個命令終於對我有用。

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

我有同樣的問題,但是用自制軟件重新安裝postgresql並不能解決問題。 但是,此命令為我做到了:

sudo env ARCHFLAGS="-arch x86_64" gem install pg

我可以通過從Heroku安裝Postgres.app並刪除我現有的postgresql安裝來使其工作。 您可以在此處下載該應用:

http://postgresapp.com/

brew remove postgresql

bundle install

如果您不使用brew,請點擊這里,從Postgres.app獲取更多卸載文檔的鏈接。

http://postgresapp.com/documentation#toc_16

我只是通過這張車票開始運行的:

運行捆綁安裝時如何為gem安裝傳遞參數?

bundle config build.pg --with-pg-config=/path/to/pg_config
bundle install

就像Matt,Ranjan和Peter Mellett都說過的那樣,您必須找到正確的pg_config位置,Mountain Lion所處的位置似乎與rubygems不太匹配,所以如果您發現舊版本像

/Library/PostgreSQL/bin/pg_config

那么您可以在安裝之前在bundle config中進行設置。

我的情況是從Lion升級到Mountain Lion。

Homebrew在/usr/local/bin/pg_ctl安裝了pg_ctl ,所以對我來說命令是:

env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/bin/pg_ctl

對於使用Kubuntu 13.04並使用一鍵式工具安裝pg的用戶,pg config位於其他文件夾中,因此命令:

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

暫無
暫無

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

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