gpt4 book ai didi

ruby-on-rails - PostgreSQL gem for rails 不会安装,即使同时安装了 home brew 和 app

转载 作者:数据小太阳 更新时间:2023-10-29 06:51:23 26 4
gpt4 key购买 nike

我试过按照这个answer让 gem 工作,但它不会。我设置了我的项目,这样各个项目都有自己的 gem ,而不是生活在全局空间中的所有主题 gem ,然后我使用 binstubs 来允许我做 bin/rails.

因此,每个项目的所有 gem 都安装到 .bundle/gems/。总是给我带来最棘手问题的是 posgresql。让我们完成这些步骤。

所以我跑:

bundle

它爆炸说:

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 上安装了 home 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

从那里我尝试了 bundle 好吧,我们回到原点,因为即使安装了 gem - 我也得到了EXACT相同的错误。

这是因为我在全局而不是本地安装 pg gem 吗?我怎样才能解决这个问题?这个项目,每次我必须做一个 rm -rf .bundle/gems 一遍又一遍地导致这个确切的问题。

我应该指出,即使我使用 home brew psql pg_config 我也会遇到同样的错误 执行上述所有步骤,仅使用 home brew 版本,结果相同。

最佳答案

最后是:

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 need

you can add this line to your ~/.profile or similar: export
ARCHFLAGS="-arch x86_64"

如需进一步阅读,请参阅:This README for OSX

关于ruby-on-rails - PostgreSQL gem for rails 不会安装,即使同时安装了 home brew 和 app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28033158/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com