【问题标题】:Could not create Makefile when installing ruby gems安装 ruby​​ gem 时无法创建 Makefile
【发布时间】:2013-02-03 17:43:42
【问题描述】:

我正在运行OSX 10.8.2,Xcode 安装了命令行工具。

我正在尝试捆绑,并且在一些宝石上(我将在底部指定)我得到以下内容:

ERROR: Failed to build gem native extension

...

Could not create Makefile due to some reason

到目前为止,我在gem 'pg'gem 'binding_of_caller' 上遇到了错误

我认为该错误与无法创建 Makefile 有关,但找不到任何有助于解决该错误的内容。我在下面粘贴了完整的错误:

我不知道该怎么办。

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.

编辑:我正在使用 rbenv 管理 ruby​​ 版本,它说我正在运行 1.9.3 -p385系统 ruby​​ 是旧版本,但据我所知,这不重要。

我通过homebrew 安装了postgresql

编辑 2:

我尝试切换到 RVM 进行 ruby​​ 管理,但又出现了一个 make 错误:

Error running 'make -j2', please read ... ruby-1.9.3-p385/make.log
There has been an error while running make. Halting the installation.

文件make.log不存在...

【问题讨论】:

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


    【解决方案1】:

    您需要安装 postgres。您需要来自http://deveiate.org/code/pg/README_rdoc.html

    • Ruby 1.8.7-p249 或 1.9.3-p0。
    • PostgreSQL 8.3.x(带有头文件、-dev 包等)。

    如果您使用的是 brew,只需

    brew install postgresql
    

    就 binding_of_caller 而言,您使用的是什么版本的 ruby​​?

    【讨论】:

    • rbenv 说我正在使用 ruby​​ 版本 1.9.3 p-385,我在其他机器上使用它没问题。我刚刚做了 brew install postgresql 并安装了它。尝试与我的 gemfile 中的 pg gem 捆绑时,我仍然遇到同样的错误。当我尝试使用 sudo gem install pg 安装 gem 时,我也会遇到同样的错误
    • 我只是输入 bundle 或 bundle install
    • 另外,请参阅我的问题的编辑
    • 顺便感谢您的帮助。
    【解决方案2】:

    所以我通过安装 pg 的sudo env ARCHFLAGS="-arch x86_64" gem install pg 解决了这个问题,但是现在我在尝试创建数据库、运行服务器等时遇到了不同的问题。我将为这些问题创建另一个问题。

    【讨论】:

    • ack,我本来打算这样做,但认为这不是你的问题。对不起
    猜你喜欢
    • 2016-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-02
    • 2011-04-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-18
    相关资源
    最近更新 更多