简体   繁体   English

在豹升级到狮子后安装pg gem并运行服务器时出错

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

Used a time machine backup to sync files from my macbook running Leopard to my macbook pro running Lion. 使用时间机器备份将文件从运行Leopard的Macbook同步到运行Lion的Macbook Pro。 After having trouble pushing to heroku due to the fact that I was running sqlite3, I went down a rabbit hole in trying to get a pg gem installed. 由于我正在运行sqlite3而无法将其推送到heroku之后,我陷入了困境,试图安装pg gem。

gem install pg

yields: 产量:

        /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.

I'm a Unix noob and fear there's something deeply wrong with the file structure that was created by time machine in mashing up 32 bit leopard with 64 bit lion. 我是Unix新手,我担心时间机器在将32位豹和64位狮子混在一起时创建的文件结构存在严重问题。 Steps I've taken so far. 到目前为止,我已采取的步骤。

Reinstalled XCode 重新安装了XCode

Xcode 4.3.3
Build version 4E3002

Installed command line tools in XCode from preferences. 通过首选项在XCode中安装了命令行工具。

updated to rvm 1.14.6 (master) with 更新为rvm 1.14.6(master)

rvm get head

Banged head against wall trying to install postgre locally with macports. 被撞的头对墙壁尝试与macports本地安装postgre。 uninstalled macports and installed homebrew 卸载macports并安装自制软件

Followed recs from 关注的记录来自

brew doctor

then 然后

brew install postgresql brew安装postgresql

ran into python issues and followed advice to install w/o python 遇到python问题,并按照建议安装了w / o python

brew install --no-python postgresql

seemed to get a clean install of postgresql, but my output from 似乎可以干净安装PostgreSQL,但是我的输出

gem install pg 

is still: 还是:

        /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.

Also tried 也尝试过

bundle install

and

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

with the same results My productivity for the last 7 hours has dropped to nothing. 结果相同我最近7个小时的工作效率几乎没有。 Can't find the relevant mkmf.log file. 找不到相关的mkmf.log文件。 Any other ideas? 还有其他想法吗?

EDIT: 编辑:

found mkmf.log. 找到了mkmf.log。 Here are relevant contents: 以下是相关内容:

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

The file you found was mkmf.rb , not mkmf.log . 您找到的文件是mkmf.rb ,而不是mkmf.log The mkmf.log will look something like this at the beginning: 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 */

You can find it in the 'ext' directory in the unpacked gem. 您可以在解压缩的gem中的“ ext”目录中找到它。 Under bash, this works for me: 在bash下,这对我有用:

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

Under OSX, failing on the first header is almost always a sign of some problem with your compiler setup, especially if it found your pg_config (and it looks like yours did). 在OSX下,第一个标头失败几乎总是表明您的编译器设置出现问题,尤其是当它找到pg_config (看起来像您的pg_config )。 Look to see that the 'gcc' at the beginning of the command in quotes actually exists on your machine. 看看在命令中以引号开头的'gcc'实际上存在于您的计算机上。 In my case that's /usr/bin/gcc-4.2 . 在我的情况下是/usr/bin/gcc-4.2 If that's missing, you'll need to fix that before any extension will install correctly from source. 如果缺少此功能,则需要先修复此问题,然后才能从源代码正确安装任何扩展程序。

If, on the other hand, your gcc does exist, attach the mkmf.log file, which will usually contain the clues necessary to point you in the right direction. 另一方面,如果您的gcc存在,请附加mkmf.log文件,该文件通常包含将您指向正确方向的必要线索。

Restarted, and noticed that somehow PostgreSQL had been added as a user(!). 重新启动,并注意到以某种方式将PostgreSQL添加为用户(!)。 Deleted the user, added gem 'pg' to the gemfile and bundle installed, and the whole thing went smoothly. 删除用户,将gem'pg'添加到gemfile并安装捆绑包,整个过程进行顺利。 Not sure what bizarreness in the installation process could have caused that to happen. 不知道安装过程中有什么怪异现象会导致这种情况发生。 I didn't change any defaults in the installation - but my guess is a problem with using an out of date version of macports. 我没有更改安装中的任何默认设置-但是我的猜测是使用过时的Macports版本存在问题。

For those in a similar situation, I'd recommend 1) never switch OS's with a time machine backup. 对于处于类似情况的用户,我建议1)切勿使用时间机器备份切换操作系统。 2) Clean install xcode, xcode developer tools (from xcode preferences menu), and homebrew. 2)清洁安装xcode,xcode开发人员工具(从xcode首选项菜单)和自制软件。 3) force update rvm 4) install postgresql locally with brew install postgresql. 3)强制更新rvm 4)使用brew install postgresql在本地安装postgresql。 5) Restart and try bundle installing the pg gem again. 5)重新启动并尝试再次捆绑安装pg gem。 I did a lot of stuff, but I think those are the steps that I think worked. 我做了很多工作,但是我认为这些是我认为可行的步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM