簡體   English   中英

在豹升級到獅子后安裝pg gem並運行服務器時出錯

[英]Error Installing pg gem and running server after leopard to lion upgrade

使用時間機器備份將文件從運行Leopard的Macbook同步到運行Lion的Macbook Pro。 由於我正在運行sqlite3而無法將其推送到heroku之后,我陷入了困境,試圖安裝pg gem。

gem install pg

產量:

        /Users/taylorjackson/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb 
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... *** 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.

我是Unix新手,我擔心時間機器在將32位豹和64位獅子混在一起時創建的文件結構存在嚴重問題。 到目前為止,我已采取的步驟。

重新安裝了XCode

Xcode 4.3.3
Build version 4E3002

通過首選項在XCode中安裝了命令行工具。

更新為rvm 1.14.6(master)

rvm get head

被撞的頭對牆壁嘗試與macports本地安裝postgre。 卸載macports並安裝自制軟件

關注的記錄來自

brew doctor

然后

brew安裝postgresql

遇到python問題,並按照建議安裝了w / o python

brew install --no-python postgresql

似乎可以干凈安裝PostgreSQL,但是我的輸出

gem install pg 

還是:

        /Users/taylorjackson/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb 
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... *** 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.

也嘗試過

bundle install

bundle config build.pg --with-pg-config=/users/taylorjackson/postgresql/bin/pg_config
bundle install

結果相同我最近7個小時的工作效率幾乎沒有。 找不到相關的mkmf.log文件。 還有其他想法嗎?

編輯:

找到了mkmf.log。 以下是相關內容:

def have_devel?
  unless defined? $have_devel
    $have_devel = true
    $have_devel = try_link(MAIN_DOES_NOTHING)
  end
  $have_devel
end

def try_do(src, command, &b)
  unless have_devel?
    raise <<MSG
The complier failed to generate an executable file.
You have to install development tools first.
MSG
  end
  begin
    src = create_tmpsrc(src, &b)
    xsystem(command)
  ensure
    log_src(src)
    rm_rf 'conftest.dSYM'
  end
end

您找到的文件是mkmf.rb ,而不是mkmf.log mkmf.log如下所示:

find_executable: checking for pg_config... -------------------- yes

--------------------

find_header: checking for libpq-fe.h... -------------------- yes
"/usr/bin/gcc-4.2 -o conftest -I/Users/mgranger/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/mgranger/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/mgranger/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1 -I. -I/Users/mgranger/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/include  -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/mgranger/.rvm/rubies/ruby-1.9.3-p194/lib -L/Users/mgranger/.rvm/usr/lib -L. -L/usr/local/lib -L/usr/lib     -lruby.1.9.1  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

您可以在解壓縮的gem中的“ ext”目錄中找到它。 在bash下,這對我有用:

less $(dirname $(gem which pg))/../ext/mkmf.log

在OSX下,第一個標頭失敗幾乎總是表明您的編譯器設置出現問題,尤其是當它找到pg_config (看起來像您的pg_config )。 看看在命令中以引號開頭的'gcc'實際上存在於您的計算機上。 在我的情況下是/usr/bin/gcc-4.2 如果缺少此功能,則需要先修復此問題,然后才能從源代碼正確安裝任何擴展程序。

另一方面,如果您的gcc存在,請附加mkmf.log文件,該文件通常包含將您指向正確方向的必要線索。

重新啟動,並注意到以某種方式將PostgreSQL添加為用戶(!)。 刪除用戶,將gem'pg'添加到gemfile並安裝捆綁包,整個過程進行順利。 不知道安裝過程中有什么怪異現象會導致這種情況發生。 我沒有更改安裝中的任何默認設置-但是我的猜測是使用過時的Macports版本存在問題。

對於處於類似情況的用戶,我建議1)切勿使用時間機器備份切換操作系統。 2)清潔安裝xcode,xcode開發人員工具(從xcode首選項菜單)和自制軟件。 3)強制更新rvm 4)使用brew install postgresql在本地安裝postgresql。 5)重新啟動並嘗試再次捆綁安裝pg gem。 我做了很多工作,但是我認為這些是我認為可行的步驟。

暫無
暫無

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

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