gpt4 book ai didi

ruby-on-rails - 无法使用 Mavericks 在我的 Mac 上安装 PG gem

转载 作者:太空宇宙 更新时间:2023-11-03 16:50:40 26 4
gpt4 key购买 nike

我正在尝试安装 pg gem,以便再次使用我的 Rails 项目。但是我得到这个错误:

Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.

/Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb checking for pg_config... no No pg_config... trying anyway. If

building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header * 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=/Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/bin/ruby --with-pg --without-pg --with-pg-config --without-pg-config --with-pg_config --without-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}/

Gem files will remain installed in /Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/pg-0.17.0 for inspection. Results logged to /Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/pg-0.17.0/ext/gem_make.out

我尝试了在 stackoverflow 上找到的所有内容,但仍然出现此错误。

如果我尝试使用 brew 安装 postgresql,我会收到以下警告:

Warning: postgresql-9.2.4 already installed, it's just not linked

如果我尝试链接

brew link postgresql Linking /usr/local/Cellar/postgresql/9.2.4... Warning: Could not link postgresql. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/postgresql/9.2.4/share/man/man7/WITH.7 /usr/local/share/man/man7 is not writable. You should change its permissions.

请帮忙

注意:我已经为特立独行者安装了命令行工具。


如果我使用 homebrew 卸载并尝试再次安装,我会收到此错误:

==> Downloading http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.bz2

################################################################## 100.0%

==> Patching patching file src/pl/plpython/Makefile patching file contrib/uuid-ossp/uuid-ossp.c ==> ./configure --prefix=/usr/local/Cellar/postgresql/9.2.4 --datadir=/usr/local/Cellar/postgresql/9.2.4/share/postgresql --docdir=/usr/local/Cellar/p ==> make install-world ==> Caveats

Build Notes

If builds of PostgreSQL 9 are failing and you have version 8.x installed, you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510

Create/Upgrade a Database

If this is your first install, create a database with: initdb /usr/local/var/postgres -E utf8

To migrate existing data from a previous major version (pre-9.2) of PostgreSQL, see:
http://www.postgresql.org/docs/9.2/static/upgrading.html

Loading Extensions

By default, Homebrew builds all available Contrib extensions. To see a list of all available extensions, from the psql command line, run:
SELECT * FROM pg_available_extensions;

To load any of the extension names, navigate to the desired database and run: CREATE EXTENSION [extension name];

For instance, to load the tablefunc extension in the current database, run: CREATE EXTENSION tablefunc;

For more information on the CREATE EXTENSION command, see:
http://www.postgresql.org/docs/9.2/static/sql-createextension.html For more information on extensions, see:
http://www.postgresql.org/docs/9.2/static/contrib.html

Other

Some machines may require provisioning of shared memory:
http://www.postgresql.org/docs/9.2/static/kernel-resources.html#SYSVIPC When installing the postgres gem, including ARCHFLAGS is recommended: ARCHFLAGS="-arch x86_64" gem install pg

To install gems without sudo, see the Homebrew wiki.

To have launchd start postgresql at login: ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents Then to load postgresql now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist Or, if you don't want/need launchctl, you can just run: pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start Warning: Could not link postgresql. Unlinking... Error: The brew link step did not complete successfully The formula built, but is not symlinked into /usr/local You can try again using `brew link postgresql' ==> Summary 🍺 /usr/local/Cellar/postgresql/9.2.4: 2831 files, 38M, built in 4.9 minutes


解决方案:

我执行此命令以更改文件夹的权限:

sudo chown jeanosorio /usr/local/share/man/man7

然后

brew link postgresql Linking /usr/local/Cellar/postgresql/9.3.1... 421 symlinks created

最后:

sudo ARCHFLAGS="-arch x86_64" gem install pg

Fetching: pg-0.17.0.gem (100%) Building native extensions. This could take a while... Successfully installed pg-0.17.0

最佳答案

如果您想避免使用 MacPorts,您可以下载 Postgres App并将其放入应用程序目录。

然后,指定新下载的pg_config的位置:

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config

如果遇到缺少 header 的问题,请尝试指定应用程序的 include 目录:

gem install pg -- --with-pg-include='/Applications/Postgres.app/Contents/Versions/latest/include/'

关于ruby-on-rails - 无法使用 Mavericks 在我的 Mac 上安装 PG gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22821556/

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