【发布时间】:2022-10-05 13:41:49
【问题描述】:
我在使用rails new Project --database=postgresql 安装我的rails 项目时遇到了这个错误
当我尝试安装捆绑包时,会弹出以下错误:
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies.....
Using rake 13.0.6
Using concurrent-ruby 1.1.10
Using racc 1.6.0
Using crass 1.0.6
Using rack 2.2.4
Using minitest 5.16.2
Using builder 3.2.4
Using marcel 1.0.2
Using websocket-extensions 0.1.5
Using digest 3.1.0
Using nio4r 2.5.8
Using mini_mime 1.1.2
Using erubi 1.11.0
Using bindex 0.8.1
Using timeout 0.3.0
Using bundler 2.3.17
Using matrix 0.4.2
Using msgpack 1.5.4
Using public_suffix 4.0.7
Using io-console 0.5.11
Using strscan 3.0.4
Using method_source 1.0.0
Using zeitwerk 2.6.0
Using childprocess 4.1.0
Using rexml 3.2.5
Using thor 1.2.1
Using rubyzip 2.3.2
Using websocket 1.2.9
Using i18n 1.12.0
Using tzinfo 2.0.5
Using nokogiri 1.13.8 (x86_64-linux)
Using rack-test 2.0.2
Using sprockets 4.1.1
Using websocket-driver 0.7.5
Using puma 5.6.4
Using mail 2.7.1
Using net-protocol 0.1.3
Using bootsnap 1.13.0
Using addressable 2.8.0
Using reline 0.3.1
Using regexp_parser 2.5.0
Using activesupport 7.0.3.1
Using loofah 2.18.0
Using net-smtp 0.3.1
Using xpath 3.2.0
Using irb 1.4.1
Using net-imap 0.2.3
Using selenium-webdriver 4.4.0
Using rails-dom-testing 2.0.3
Using activemodel 7.0.3.1
Using rails-html-sanitizer 1.4.3
Using capybara 3.37.1
Using net-pop 0.1.1
Using globalid 1.0.0
Using activerecord 7.0.3.1
Using actionview 7.0.3.1
Using debug 1.6.2
Using actionpack 7.0.3.1
Using webdrivers 5.0.0
Using jbuilder 2.11.5
Using activejob 7.0.3.1
Using actioncable 7.0.3.1
Using activestorage 7.0.3.1
Using railties 7.0.3.1
Using actionmailbox 7.0.3.1
Using actiontext 7.0.3.1
Using actionmailer 7.0.3.1
Using importmap-rails 1.1.5
Using stimulus-rails 1.1.0
Using turbo-rails 1.1.1
Using web-console 4.2.0
Using sprockets-rails 3.4.2
Using rails 7.0.3.1
使用本机扩展安装 pg 1.4.3 Gem::Ext::BuildError: 错误: 无法构建 gem 原生扩展。
current directory:
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.4.3/ext
/home/christian/.rbenv/versions/3.1.2/bin/ruby -I
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0 -r
./siteconf20220811-57965-mz3s1i.rb extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /usr/bin/pg_config
Using libpq from /usr/lib/x86_64-linux-gnu
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*****************************************************************************
Unable to find PostgreSQL client library.
Please install libpq or postgresql client package like so:
sudo apt install libpq-dev
sudo yum install postgresql-devel
sudo zypper in postgresql-devel
sudo pacman -S postgresql-libs
or try again with:
gem install pg -- --with-pg-config=/path/to/pg_config
or set library paths manually with:
gem install pg -- --with-pg-include=/path/to/libpq-fe.h/
--with-pg-lib=/path/to/libpq.so/
*** 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/christian/.rbenv/versions/3.1.2/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-gvl-unlock
--disable-gvl-unlock
--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/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/pg-1.4.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.4.3 for
inspection.
Results logged to
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/pg-1.4.3/gem_make.out
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in
`run'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:47:in
`block in build'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/tempfile.rb:317:in `open'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in
`build'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in
`build_extension'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in
`block in build_extensions'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in
`each'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in
`build_extensions'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/installer.rb:853:in
`build_extensions'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/rubygems_gem_installer.rb:71:in
`build_extensions'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/source/rubygems.rb:209:in
`install'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/installer/gem_installer.rb:54:in
`install'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/installer/parallel_installer.rb:186:in
`do_install'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:62:in
`apply_func'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:57:in
`block in process_queue'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:54:in
`loop'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:54:in
`process_queue'
/home/christian/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:91:in
`block (2 levels) in create_threads'
安装pg(1.4.3)时出错,Bundler不能 继续
.
In Gemfile:
pg
最重要的是,创建了项目的 repo,但没有 Gemfile.lock
我的电脑上安装了 PostgreSQL。
我正在使用Ubutu 22.04.1
我已经尝试了很多建议,但仍然找不到出路。
如果有人可以提供帮助,我将不胜感激。
【问题讨论】:
-
你运行
sudo apt install libpq-dev吗? -
是的,是的,当我运行该命令时,我说的是抛出一个错误,比如未满足的包
标签: ruby-on-rails