簡體   English   中英

無法安裝 gem 'pg'

[英]Unable to install gem 'pg'

我正在嘗試捆綁安裝我從 bitbucket 克隆的 ruby-on-rails 項目,並且在安裝 pg 時它被終止,所以我嘗試單獨安裝 pg。

當我運行 gem install pg -v '0.20.0' 時,會顯示以下日志

Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

    current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pg-0.20.0/ext
D:/Ruby31-x64/bin/ruby.exe -I D:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 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=D:/Ruby31-x64/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:

  D:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/pg-0.20.0/mkmf.log   

extconf failed, exit code 1

Gem files will remain installed in D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pg-0.20.0 for inspection.
Results logged to D:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/pg-0.20.0/gem_make.out

我該如何解決?

  • windows 10
  • 超級終端

運行此命令:

gem install pg -v '0.20.0' -- --with-pg-config='D:\PostgreSQL\14\bin\pg_config'

這有助於您根據本地系統放置所需的任何版本而不是 0.20.0 和 pg_config 的路徑。

暫無
暫無

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

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