简体   繁体   English

在Mountain Lion安装后无法安装postgresql gem

[英]Cannot get postgresql gem installed after Mountain Lion install

I have been trying for some time now to get my Rails development environment back up since I upgraded from Lion to Mountain Lion. 自从我从Lion升级到Mountain Lion以来,我已经尝试了一段时间来恢复我的Rails开发环境。 The problem is specifically installing the pg-0.14.0 (postgresql) gem. 问题是专门安装pg-0.14.0(postgresql)gem。

I have tried the instructions on this post but with no luck. 我已尝试过这篇文章的说明但没有运气。 I have tried uninstalling Postgres with Homebrew and then reinstalling it. 我尝试用Homebrew卸载Postgres然后重新安装它。 Nothing is working. 什么都行不通。 If I try to install this gem I recieve this error: 如果我尝试安装此gem我收到此错误:

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
checking for pg_config... yes 
Using config values from /usr/local/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.

Where can I find mkmf.log ? 我在哪里可以找到mkmf.log Can anyone give me a suggestion on how to install the pg gem again? 谁能给我一个关于如何再次安装pg gem的建议?

update I was able to locate my mkmf.log file using : 更新我能够使用以下命令找到我的mkmf.log文件:

find / -name mkmf.log 2>/dev/null find / -name mkmf.log 2> / dev / null

There are several failed xcrun calls like the one below: 有几个失败的xcrun调用,如下所示:

have_library: checking for PQconnectdb() in -llibpq... -------------------- no have_library:在-llibpq中检查PQconnectdb()... -------------------- no

"xcrun cc -o conftest -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/Cellar/postgresql/9.1.4/include -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64 -L/usr/local/Cellar/postgresql/9.1.4/lib -lruby -llibpq -lpthread -ldl -lobjc " ld: library not found for -llibpq clang: error: linker command failed with exit code 1 (use -v to see invocation) “xcrun cc -o conftest -I。-I / System / Library / Frameworks / Ruby.framework / Versions / 1.8 / usr / lib / ruby​​ / 1.8 / universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I / usr /local/Cellar/postgresql/9.1.4/include -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common conftest.c -L.-L / System /Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L.-arch i386 -arch x86_64 -L / usr / local / Cellar / postgresql / 9.1.4 / lib -lruby -llibpq -lpthread -ldl - lobjc“ld:找不到-llibpq clang的库:错误:链接器命令失败,退出代码为1(使用-v查看调用)

Why am I getting errors when running xcrun? 运行xcrun时为什么会出错? Has anyone seen this? 有没有人见过这个?

Thanks! 谢谢!

The error says it right there: 错误说它就在那里:

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)

It can't find libpq, or its tests that try to compile a test program and link to it are failing. 它找不到libpq,或者试图编译测试程序并链接到它的测试失败。 Since it's finding /usr/local/bin/pg_config it should know where the Pg libraries and headers are, so the problem is probably an error in the test compile. 因为它找到/usr/local/bin/pg_config它应该知道Pg库和头文件的位置,所以问题可能是测试编译中的错误。

To learn more you will need to examine mkmf.log . 要了解更多信息,您需要检查mkmf.log Run

find . -name mkmf.log

from within the directory you ran the gem install command, that'll probably locate it. 从您运行gem install命令的目录中,可能会找到它。 Update your post with its contents. 更新您的帖子及其内容。

I got this resolved finally. 我终于解决了这个问题。 I used RVM to uninstall ruby and re-install ruby version 1.9.3. 我使用RVM卸载ruby并重新安装ruby版本1.9.3。 This allowed me to run 'bundle install' without a problem. 这使我可以毫无问题地运行“捆绑安装”。 I checked that all gems where loaded (gem list). 我检查了所有装载的宝石(宝石清单)。 However my rails application could not locate the postgres socket file at this point. 但是我的rails应用程序此时无法找到postgres套接字文件。 The same problem is detailed here. 这里详细说明同样的问题 Rather than locating the postgresql.conf file, changing permissions on it, and editing it I just uninstalled my current version of Postgres and downloaded the latest One-Click installer from PostGres. 而不是找到postgresql.conf文件,更改它的权限,并编辑它我只是卸载了我当前版本的Postgres并从PostGres下载了最新的One-Click安装程序。 When I ran the installer again it detected the other PostGres installation and updated it. 当我再次运行安装程序时,它检测到其他PostGres安装并更新它。 This updated the configurations for me and all is well again. 这为我更新了配置,一切都很好。

I hope this might help some other poor rails dev upgrading to Mountain Lion :) 我希望这可能会帮助其他一些可怜的rails dev升级到Mountain Lion :)

I've struggled a few hours with this too and couldn't find anything working in my setup. 我也用这个挣了几个小时,在我的设置中找不到任何工作。

I ended up using postgres.app . 我最终使用postgres.app This is a packaged version of Postgres released by the people at Heroku. 这是Heroku的人们发布的Postgres的打包版本。 They say it's "the easiest way to run postgreSQL on the Mac". 他们说这是“在Mac上运行postgreSQL的最简单方法”。 Based on my experience, this is true! 根据我的经验,这是真的!

Just drop it into you Applications folder and you're done! 只需将其放入“应用程序”文件夹即可! (I've just had to restart to free port 5432). (我只需要重新启动以释放端口5432)。

Side note: they also have released an application called Induction to manage and query your databases, but for the moment it is unusable in Mountain Lion. 旁注:他们还发布了一个名为Induction的应用程序来管理和查询您的数据库,但目前它在Mountain Lion中无法使用。

如果你有Mountain Lion和XCODE 4.4.1你没有命令工具go和dowload from https://developer.apple.com/downloads/index.action

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

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