当我运行 bundle 或尝试单独安装它时,我无法安装 pg gem。我得到的错误是:“无法创建 Makefile。” 我正在运行 Mountain Lion,安装了 Xcode,并安装了命令行工具。我还通过自制软件安装了 Postregsql。
我相信这个错误是因为我无法创建 makefile,它已经作为阻止我做其他事情的错误浮出水面。
我得到的完整错误如下。
此错误发生在捆绑期间。其他 gem 安装得很好,或者被标记为正在使用,然后这个错误会终止包,而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 s
、rake db:create:all
或rake db:migrate
. 我将创建一个单独的问题来追踪这些问题......