簡體   English   中英

無法在導軌上的 ruby 中安裝 pg gem

[英]unable to install pg gem in ruby on rails

我正在嘗試安裝 '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

許多 SO 搜索表明

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

我嘗試了很多解決方案,但從其官方網站安裝 Postgres 對我來說很有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM