ruby-on-rails - gem install pg 给出 Gem::Ext::BuildError: ERROR: Failed to build gem native extension in ruby '2.2.3' and 'rails', '4.2.7.1' in ubuntu 18.04 LTS
问题描述
我正在尝试建立一个具有 ruby 2.2.3 和 rails 版本 4.2.7.1 的 rails 项目。它使用 PostgreSQL 作为数据库。我可以在 GemFile 中看到 gem 'pg' 条目。我做了 bundle install 来安装依赖项,但是在安装 pg gem 时,它给了我以下错误。我的 ubuntu 18.04 LTS 系统上没有安装 postgreSQL。这可能是我收到此错误的原因。请帮忙。我得到的错误:
**
**Fetching pg 1.2.3
Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/pc-123/.rvm/gems/ruby-2.2.3/gems/pg-1.2.3/ext
/home/pc-123/.rvm/rubies/ruby-2.2.3/bin/ruby -I /home/pc-123/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0 -r ./siteconf20200822-841-6si3xn.rb
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=/home/pc-123/.rvm/rubies/ruby-2.2.3/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--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}/lib
**
解决方案
您必须安装该libpq-dev
软件包。您正在使用 Ubuntu,所以:
sudo apt install libpq-dev
推荐阅读
- bash - 用连续的数字重命名文件,保留原始文件名
- fortran - 在 fortran 写入中转义引号并删除双换行符
- matplotlib - 为matplotlib中的每个plt.plot添加平均线?
- python - 仍然不知道如何模拟导入的库 - Python
- html - 禁用 Chrome 自动填充功能不适用于多个输入字段
- typescript - 如何将参数绑定到 .then 承诺?
- swift - 如何防止 Xcode 重复将 Swift 标准库复制到我的应用程序中?
- python - 无法从电报频道获取 user_left 事件
- java - Spring Webflux 是否在每个请求的单个线程中调用单个 HandlerFunction?
- ios - 如何使用 UILongPressGestureRecognizer 计算长按按钮的时间