我试过跟随这个
answer来让宝石工作,但它不会.我有我的项目设置,以便个人项目有自己的宝石而不是生活在全球空间的所有主题宝石,然后我使用binstubs允许我做bin / rails之类的事情.
因此,对于每个项目,所有宝石都安装到.bundle / gems /.总是给我最棘手问题的是posgresql.让我们完成这些步骤.
所以我跑:
束
它爆炸说:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config Using config values from /Applications/Postgres.app/Contents/Versions/9.3/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/2.0/usr/bin/ruby --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/ --with-pqlib --without-pqlib --with-libpqlib --without-libpqlib --with-ms/libpqlib --without-ms/libpqlib Gem files will remain installed in /Users/Adam/Documents/Rails-Projects/AisisPlatform/.bundle/gems/gems/pg-0.18.1 for inspection. Results logged to /Users/Adam/Documents/Rails-Projects/AisisPlatform/.bundle/gems/gems/pg-0.18.1/ext/gem_make.out An error occurred while installing pg (0.18.1),and Bundler cannot continue. Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.
那么,因为我在9.4.0安装了家用Brew版本并安装了posgresql.app然后我做了:
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
接下来,因为我使用18.1
gem install pg -v '0.18.1'
我得到了:
Building native extensions. This Could take a while... Successfully installed pg-0.18.1 invalid options: -f fivefish (invalid options are ignored) Parsing documentation for pg-0.18.1 Done installing documentation for pg after 2 seconds 1 gem installed
从那里我尝试捆绑嗯我们回到原点,因为即使安装了宝石 – 我得到了完全相同的错误.
这是因为我在全局安装pg gem而不是本地安装吗?我怎样才能解决这个问题?这个项目,每次我必须做一个rm -rf .bundle / gems一次又一次地引起这个问题.
我应该指出即使我使用家庭酿造psql pg_config也会得到同样的错误.执行上述所有步骤,只需使用家庭酿造版本,结果相同.
解决方法
在一天结束时它是:
ARCHFLAGS="-arch x86_64" bundle install
这对我有用.
理由是:
by default it tries to compile a universal binary,which apparently
fails… so that environment variable makes it only compile the x86
version which is all you needyou can add this line to your
~/.profile
or similar:export
ARCHFLAGS="-arch x86_64"
如需进一步阅读,请参阅:This README for OSX