ruby-on-rails - 无法在 ruby on rails 中安装 pg gem
问题描述
我正在尝试安装 'pg' gem 并收到以下错误:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/thomas/.rvm/gems/ruby-2.7.1/gems/pg-1.2.3/ext
/usr/share/rvm/rubies/ruby-2.7.1/bin/ruby -I
/usr/share/rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0 -r
./siteconf20200423-27933-r303r1.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side
extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side
extension or libpq-dev for building a client-side application.
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=/usr/share/rvm/rubies/ruby-2.7.1/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
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/home/thomas/.rvm/gems/ruby-2.7.1/extensions/x86_64-linux/2.7.0/pg-1.2.3/mkmf.log
extconf failed, exit code 1
许多搜索结果表明
sudo apt-get install libpq-dev
但这给了
Err:1 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 libpq5 amd64 11.4-1.pgdg16.04+1
404 Not Found [IP: 87.238.57.227 80]
Err:2 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 libpq-dev amd64 11.4-1.pgdg16.04+1
404 Not Found [IP: 87.238.57.227 80]
E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-11/libpq5_11.4-1.pgdg16.04+1_amd64.deb 404 Not Found [IP: 87.238.57.227 80]
E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-11/libpq-dev_11.4-1.pgdg16.04+1_amd64.deb 404 Not Found [IP: 87.238.57.227 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
并运行建议的
apt-get update --fix-missing
给出与上面相同的错误。有任何想法吗?我看过很多有同样问题的帖子,通常提供类似的解决方案,但它们似乎在这里不起作用。提前致谢
解决方案
sudo apt-get install libpq-dev
推荐阅读
- android - 在 imageview 上添加阴影
- python - 如何将所有数字存储在一个名为 numbers 的变量中
- javascript - 使用 Javascript 初始化数据与使用 MySQL 进行数据检索之间的性能差异?
- android - 如何将选中的单选按钮传递给 Kotlin 中的其他活动
- jboss - 如何指定 JBoss WildFly 部署应加载其 lib 模块并导入服务?
- javascript - 如何在 Angular 8 中配置 Oauth2.0
- unity3d - 面板不变
- c# - 从数据网格中删除选定的行
- node.js - node.js:将列表从节点 js 代码传递到 hbs html 页面并不总是有效(有时给我输出,有时是空的,没有输出)
- google-cloud-platform - GCP Redmine 单击以部署 以管理员身份登录