2014-12-02 186 views
0

在ubuntu 14.04中,我無法安裝pg gem,但是我也安裝了libpg-dev。無法安裝gem pg - 無法找到PostgreSQL客戶端庫(libpq)

sudo apt-get install libpq-dev 

Here我可以看到一些其他人有同樣的問題。

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

    /home/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -r ./siteconf20141202-24533-1xrmav0.rb 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... no 
checking for PQconnectdb() in -llibpq... no 
checking for PQconnectdb() in -lms/libpq... no 
Can't find the PostgreSQL client library (libpq) 
*** 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 
    --without-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=/home/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby 
    --with-pg 
    --without-pg 
    --with-pg-config 
    --without-pg-config 
    --with-pg_config 
    --without-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}/lib 
    --with-pqlib 
    --without-pqlib 
    --with-libpqlib 
    --without-libpqlib 
    --with-ms/libpqlib 
    --without-ms/libpqlib 

extconf failed, exit code 1 

Gem files will remain installed in /home/user/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.17.1 for inspection. 
Results logged to /home/user/.rvm/gems/ruby-1.9.3-p194/extensions/x86_64-linux/1.9.1/pg-0.17.1/gem_make.out 

有什麼幫助嗎?

+0

奇怪的問題...我不知道,但嘗試紅寶石'sudo ldconfig',然後再試 – 2014-12-02 15:29:24

+0

是的,它仍然是一樣的。 – tokhi 2014-12-02 15:32:03

+0

'dpkg -S/usr/lib/libpq.so'的輸出是什麼? – blelump 2014-12-02 15:44:03

回答

2

您應該在線發佈您的mkmf.log文件,但您還需要檢查您的Ruby和PostgreSQL是否使用相同的OpenSSL版本。

可能發生的情況是,您已經通過RVM安裝了Ruby和OpenSSL,並且您的PostgreSQL正在使用該系統的版本。這會導致衝突。

+2

這對我有用。我通過linuxbrew和apt-get安裝了OpenSSL。刪除我的釀造版本,它的工作。謝謝! – anders32 2015-03-29 03:13:06

0

我猜你已經正確安裝了Postgres。你是否試圖通過這樣的標誌?

env ARCHFLAGS="-arch x86_64" gem install pg 
+0

是的,我已經嘗試過;它不工作。 – tokhi 2014-12-02 15:48:36

0

我在我的電腦上遇到同樣的問題。我只需運行rvm get stable即可更新rvm並再次運行bundle install。此pg gem安裝成功後。

+0

仍然相同'rvm -v': 'rvm 1.26.3(最新)由韋恩E.塞甘<[email protected]>,Michal Papis <[email protected]> [https://rvm.io/ ]' – tokhi 2014-12-02 15:57:30

4

運行此代碼sudo ARCHFLAGS="-arch x86_64" gem install pg -v '0.18.2',然後bundle install。它應該正確安裝pg gem。