![](/img/trans.png)
[英]error occurred while installing pg (0.15.1), and Bundler cannot continue
[英]An error occurred while installing pg (0.17.1), and Bundler cannot continue
我刚刚安装了Rails 4.0.2
,在创建新应用程序时,在捆绑阶段我得到:
Installing pg (0.17.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/Dee/.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.
我该如何解决?
此处报告了某种错误在 OS X 上安装 PG gem - 无法构建本机扩展
要在 Ubuntu 上安装依赖项,请尝试以下操作:
sudo apt-get install libpq-dev
而这
gem install pg
我在运行 Mavericks 的 Mac 上。 我的解决方案是安装Postgres 。
然后在终端安装使用自制软件和配置:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
注意:此答案已被编辑为使用当前包含在 Postgres 应用程序的发布版本中的latest
符号链接。
以前的版本建议:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
应用程序根:
注意:如果需要,请替换步骤 3 中的版本号。
我安装在 mac OSX Mavericks 下,安装了来自www.postgresapp.com的 postgres 应用程序(版本 9.2.2.0)。 潜在的问题很简单,因为 postgres 是通过应用程序安装的,所以配置文件驻留在一个位置,在没有 postgressapp 的情况下安装它时,该位置不是默认位置。 所以我们需要告诉 gem 在哪里可以找到这个文件:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
希望它有帮助
如果 gem install pg 失败,请尝试以下命令:
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
...来自PostgreSQL.app 文档
看起来您没有安装 PostgreSQL。 pg
gem 需要来自 PostgreSQL 的一些头文件来编译本机扩展。
我必须结合一切并使用
sudo env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
如果您在开发中使用 Postgres 以外的东西,而只在生产中使用 Postgres,您可以像这样将 pg gem 添加到您的 gemfile 中...
group :production do
gem 'pg', '0.17.1'
end
然后使用bundle install --without production
CentOS 用户:
sudo yum install postgresql-devel
和
gem install pg
我刚刚设置了一个新的 Macbook Pro,它是用 Catalina 预构建的。
什么对我有用:
export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
到您的.zshenv
,因为 Z shell 现在是默认终端。安装 Postgres 后,我必须运行以下命令
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
在此捆绑安装后效果很好!
希望它有帮助
我设法克服该错误的方法是:
rbenv 本地 2.1.2
捆绑安装 --path 供应商/捆绑
这为我做到了。
我需要使用 sudo
sudo gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
我在使用 Amazon 时遇到问题,无法使用 apt-get。 对于我的工作:
sudo yum install postgresql-devel
然后:
bundle install
然后再试一次:
rails serve
如果您是通过 Homebrew 安装的; gem install pg -- --with-pg-config=/usr/local/bin/pg_config
。 适用于 Ruby 2.4.6 和 pg 0.20.0。
在 mac 上,这个命令对我有用。
gem install pg -v '0.18.4' -- --with-cflags="-Wno-error=implicit-function-declaration"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.