由于某种原因无法创建Makefile

时间:2013-02-19 18:15:05

标签: ruby-on-rails ruby makefile bundle osx-mountain-lion

当我运行bundle时,或者当我尝试单独安装时,我无法安装pg gem。我得到的错误是:“无法创建Makefile。”我正在运行Mountain Lion,安装了Xcode,并安装了命令行工具。我也通过自制软件安装了Postregsql。

我认为错误是因为我无法创建makefile,因为错误导致我无法做其他事情。

我得到的完整错误如下。

捆绑期间发生此错误。其他宝石安装正常,或标记为使用,然后此错误终止捆绑installing pg (0.14.1) with native extensions

Gem::Installer::ExtensionBuildError: 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/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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib


Gem files will remain installed in /Users/ericavirtue/.bundler/tmp/75812/gems/pg-0.14.1 for inspection.
Results logged to /Users/ericavirtue/.bundler/tmp/75812/gems/pg-0.14.1/ext/gem_make.out
An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.1'` succeeds before bundling.

我真的不知道该怎么做。我已经做了两天了。

编辑:

因此,当试图找到实现解决方案的路径时,Christian Rapp建议我找到这个建议:sudo env ARCHFLAGS="-arch x86_64" gem install pg,它可以安装pg。不幸的是,当我尝试运行rails srake db:create:allrake db:migrate时,我遇到了错误。我将创建一个单独的问题来追踪这些问题......

3 个答案:

答案 0 :(得分:2)

错误是这样的:

  

找不到PostgreSQL客户端库(libpq)

您需要安装PostreSQL(我建议使用Homebrew,但可能还有其他可用的下载)并尝试再次安装gem。

答案 1 :(得分:2)

我没有在MacOS上使用自制程序,但它在哪里安装libpq? MacPorts正在使用/ opt,您的配置脚本对此一无所知。错误消息非常有用,只需提供类似

的路径即可
  

gem install pg - --with-libpqlib = / opt /...

可能您必须使用另一面旗帜来提供必要的信息

答案 2 :(得分:1)

“找不到PostgreSQL客户端库(libpq)”

这是无法创建makefile的原因。您的Postgres库,特别是libpq在您的路径上找不到。我看到你安装了Homebrew。我不使用自制软件,所以我不知道它是否为你设定了路径。