[英]gem install pg giving 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
Iam trying to set up a rails project which has ruby 2.2.3 and rails version 4.2.7.1.我正在尝试建立一个具有 ruby 2.2.3 和 rails 版本 4.2.7.1 的 rails 项目。 It uses PostgreSQL as the database.它使用 PostgreSQL 作为数据库。 I can see gem 'pg' entry in the GemFile.我可以在 GemFile 中看到 gem 'pg' 条目。 I did bundle install to install the dependencies, but when it came to installing pg gem, it is giving me the following error.我做了 bundle install 来安装依赖项,但是在安装 pg gem 时,它给了我以下错误。 I dont have postgreSQL installed on my ubuntu 18.04 LTS system.我的 ubuntu 18.04 LTS 系统上没有安装 postgreSQL。 Could this be the reason why iam getting this error.这可能是我收到此错误的原因。 Please help.请帮忙。 Error that i am getting:我得到的错误:
** **
**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
** **
You must install the libpq-dev
package.您必须安装libpq-dev
package。 You are using Ubuntu so:您正在使用 Ubuntu 所以:
sudo apt install libpq-dev
It would be smart to have PostGreSQL installed.安装 PostGreSQL 会很聪明。
This depends on what Ruby version is your interpreter using.这取决于您的解释器使用的 Ruby 版本。 A mismatch there and you can run into problems.那里不匹配,您可能会遇到问题。 Using the same version will fix your issue.使用相同的版本将解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.