2012-02-10 117 views
59

WhenI運行(作爲root)創業板安裝PG --with-PG-配置工程,束失敗

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config 

我得到以下輸出:

#-> gem instal pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config 
Building native extensions. This could take a while... 
Successfully installed pg-0.12.0 
1 gem installed 
Installing ri documentation for pg-0.12.0... 
Installing RDoc documentation for pg-0.12.0... 
#-> 

當我運行捆綁安裝:

Installing pg (0.12.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

    /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for pg_config... no 
No pg_config... trying anyway. If building fails, please try again with 
--with-pg-config=/path/to/pg_config 
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=/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby 
--with-pg 
--without-pg 
--with-pg-dir 
--without-pg-dir 
--with-pg-include 
--without-pg-include=${pg-dir}/include 
--with-pg-lib 
--without-pg-lib=${pg-dir}/lib 
--with-pg-config 
--without-pg-config 
--with-pg_config 
--without-pg_config 


Gem files will remain installed in /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg- 0.12.0 for inspection. 
Results logged to /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-0.12.0/ext/gem_make.out 
An error occured while installing pg (0.12.0), and Bundler cannot continue. 
Make sure that `gem install pg -v '0.12.0'` succeeds before bundling. 

我有libpq-fe.h安裝在/usr/pgsql-9.1/include/libpq-fe.h。所以,我試過

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config --with-pg-lib=/usr/pgsql-9.1/include/libpq-fe.h but still no go. 

任何幫助將不勝感激。

另外,我已經安裝了postgresql91-devel和ruby-devel。運行CentOS 6.

回答

148

您是否在運行前試過運行過這個bundle install

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config 

http://bundler.io/v1.3/bundle_config.html

+8

之後你是一個魔術師。非常感謝! – YuKagi 2012-02-10 21:40:34

+0

如果您使用的是MacOS + MacPorts,請參閱Lester的解決方案文章。 – Matthias 2012-08-07 09:41:06

+0

我有同樣的錯誤,但我正在使用mysql數據庫。什麼將命令請求? – 2013-03-20 13:26:57

16

如果有人使用的MacPorts安裝Postgres的,並具有發現他們pg_config問題,試試這個:

bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config 

我希望這可以幫助別人節省一些時間。乾杯!

+0

你是一個救星!!!! – 2012-05-22 17:25:42

+0

這爲我修好了,乾杯! – Matthias 2012-08-07 09:40:23

4

如果您安裝了pg_config但它不在任何路徑中,則可能會出現此錯誤。您可以將它添加到您的〜/ .bashrc中的PATH env中。

例如。

export PATH=${PATH}:/usr/pgsql-9.2/bin 
+0

這可能是源代碼而不是包管理器安裝的結果嗎?無論如何爲我工作 - 只是好奇我爲什麼遇到問題。 – FantasticSponge 2014-06-30 14:20:38

3

我不得不這樣做是爲了解決在OS X礦:

export PATH=/opt/local/lib/postgresql84/bin/:$PATH 

我不得不這樣做盡管我已經在我的道路了這一點:

[[email protected] ~] which psql84 
/opt/local/bin/psql84 

[[email protected] ~] ls -altrh /opt/local/bin/psql84 
lrwxr-xr-x 1 root admin 36B Dec 7 02:15 /opt/local/bin/psql84 -> /opt/local/lib/postgresql84/bin/psql 

我希望能幫助另一位Mac用戶解決這個問題。

+0

這一個爲我工作,謝謝。 – holms 2013-11-09 01:21:19

+0

謝謝我在Mac Yosemite上測試了這個解決方案。 – newguy 2016-02-05 14:12:40

1

試試這個:

yum install libpqxx-devel 

它與Postgr9.2。

3

Postgres gem找不到Postgres配置文件。你需要告訴它它在哪裏。在我看來,最令人愉快的解決方案是跳過Brew和MacPorts,並使用Postgres應用程序。從這裏下載並安裝:

http://postgresapp.com/

現在添加bin文件夾到您的路徑:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" 

您也不妨將它添加到您的〜/ .bash_profile中

現在安裝寶石:

gem install pg 

它應該順利。

4

我在Mac和我使用自制軟件,所以要解決這個問題,我剛安裝PostgreSQL用於釀造:

brew install postgresql 

再裝寶石。

0
gem install pg -v '0.17.1' 

對我來說算過了。

2

我正在使用Arch Linux,並且遇到類似的問題。使用sudo pacman -S libpqxx和reran然後安裝了pg gem,然後再次運行bundle install,這次它終於奏效了!

+0

我也在使用Arch Linux,這解決了我的問題! – 2015-12-04 23:17:29

+0

2016,postgresql 9.5和pg 0.18.4似乎沒有提到的解決方案(我也使用arch linux)。 – 2016-02-21 20:33:46

1

link使用建議:

gem install pg --pre 

我不能讓pg gem安裝好幾天,但這種方法終於爲我工作。希望這會有所幫助。

9

如果你不知道從哪裏你pg_config是,假設你是在Linux或Mac,你可以運行下面的命令:

which pg_config 

這將返回==>/usr/pgsql-9.1/bin/pg_config

現在使用這個路徑

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config 

現在完成bundle install

3

複製粘貼&:

bundle config build.pg --with-pg-config=`which pg_config` && bundle 

詳情:

更多信息請訪問:

你應該做的是確保「pg_config」工具自帶的Postgres是在路徑的第一件事。如果不是,或者您的路徑中第一個不是使用您要構建的Postgres安裝的路徑,則可以使用-with-pg-config選項指定路徑。

來源:https://github.com/ged/ruby-pg/blob/1f274f68c16f1af1c642db1b9d3d28aef169dc84/ext/extconf.rb#L27

0

確保你已經安裝了postgress。如果不是先安裝它。以終端爲例。

brew install postgresql 

該運行

bundle install