安装 pg -v '0.18.4' 失败在苹果电脑上

发布于 2025-01-12 11:27:59 字数 9058 浏览 2 评论 0原文

我目前正在尝试在本地运行应用程序,但遇到了 postgreSql 的一些问题。

gem install pg 给了我以下内容:

Fetching gem metadata from http://insecure.rails-assets.org/...
Fetching version metadata from http://insecure.rails-assets.org/..
Fetching gem metadata from http://insecure.rails-assets.org/...
Fetching gem metadata from https://rubygems.org/........
Fetching version metadata from http://insecure.rails-assets.org/..
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from http://insecure.rails-assets.org/..
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.4
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.5
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.5
Using globalid 0.3.6
Using activejob 4.2.5
Using mime-types 2.6.2
Using mail 2.6.3
Using actionmailer 4.2.5
Using active_link_to 1.0.3
Using activemodel 4.2.5
Using arel 6.0.3
Using activerecord 4.2.5
Using addressable 2.3.8
Using extlib 0.9.16
Using multi_json 1.11.2
Using autoparse 0.3.3
Using coderay 1.1.0
Using better_errors 2.1.1
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bootstrap_form 2.3.0
Using bundler 1.8.4
Using byebug 9.1.0 (was 8.2.0)
Using cancancan 1.13.1
Using chartkick 1.4.1
Using chunky_png 1.3.5
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.5
Using coffee-rails 4.1.0
Using concurrent-ruby 1.0.0
Using connection_pool 2.2.0
Using unf_ext 0.0.7.1
Using unf 0.1.4
Using domain_name 0.5.24
Using faker 1.6.1
Using multipart-post 2.0.0
Using faraday 0.9.2
Using ffi 1.9.10
Using font-awesome-rails 4.4.0.0
Using formatador 0.2.5
Using friendly_id 5.0.5
Using jwt 2.2.2
Using little-plugger 1.1.4
Using logging 2.0.0
Using memoist 0.12.0
Using signet 0.6.1
Using googleauth 0.4.2
Using launchy 2.4.3
Using retriable 1.4.1
Using google-api-client 0.8.6
Using groupdate 2.4.0
Using rb-fsevent 0.9.6
Using rb-inotify 0.9.5
Using listen 3.0.5
Using lumberjack 1.0.9
Using nenv 0.2.0
Using shellany 0.0.1
Using notiffany 0.0.8
Using method_source 0.8.2
Using slop 3.6.0
Using pry 0.10.3
Using guard 2.13.0
Using guard-compat 1.2.1
Using guard-minitest 2.4.4
Using tilt 2.0.1
Using haml 4.0.7
Using hashie 3.6.0
Using http-cookie 1.0.2
Using jbuilder 2.3.2
Using jquery-rails 4.0.5
Using mini_magick 4.2.7
Using multi_xml 0.5.5
Using netrc 0.10.3
Using oauth2 1.4.4
Using omniauth 1.9.1
Using omniauth-oauth2 1.7.0
Using omniauth-github 1.1.2
Using omniauth-google-oauth2 0.8.0
Using ruby-openid 2.7.0
Using rack-openid 1.3.1
Using omniauth-openid 1.0.1

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/username/.rbenv/versions/2.2.0/bin/ruby -r ./siteconf20220307-80476-1facihf.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
sh: /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config: No such file or directory
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=/Users/nahomie/.rbenv/versions/2.2.0/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-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

extconf failed, exit code 1

Gem files will remain installed in /Users/username/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/pg-0.18.4 for inspection.
Results logged to /Users/username/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-21/2.2.0-static/pg-0.18.4/gem_make.out
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.

gemfile

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  # gem 'byebug'
  gem 'byebug', '~> 9.1'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]


gem "haml"
gem "omniauth"
gem "omniauth-github"
gem "omniauth-google-oauth2", '~> 0.8.0'
gem "omniauth-openid"
gem "google-api-client"
gem "cancancan"
gem 'bootstrap_form'
gem 'friendly_id', '~> 5.0.0'
gem 'ransack'
gem 'rdiscount', require: 'tilt/rdiscount'
gem 'ruby_identicon'
gem 'sidekiq'
gem "refile", require: "refile/rails"
gem "refile-mini_magick"
gem 'simple_form'
gem 'active_link_to'
gem 'chartkick'
gem 'groupdate'
gem 'faker'
# gem 'skylight'

gem 'bundler', '>= 1.8.4'
source 'http://insecure.rails-assets.org' do
# source 'https://rails-assets.org' do
  gem 'rails-assets-bootstrap'
  gem 'rails-assets-jasny-bootstrap'
  gem 'rails-assets-handlebars'
  gem 'rails-assets-datatables'
  gem 'rails-assets-datatables-fixedcolumns'
  gem 'rails-assets-typeahead.js'
end
gem "font-awesome-rails"

# bring back removed support for respond_with
# gem 'responders', '~> 2.0'

group :production do
  gem 'rails_12factor'
  gem 'puma'
end

group :development do
  gem 'guard'
  gem 'guard-minitest'
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'quiet_assets'
  gem 'pry-rails'
end

ruby "2.2.0"

我尝试过的步骤:

bundle install

gem install pg

gem install pg -v '0.18.4

gem install pg 0.18.4

我还尝试使用所需的确切版本修改gemfile中的pg,然后运行bundle install

当我尝试运行 brew install libpq

==> Downloading https://ghcr.io/v2/homebrew/core/libpq/manifests/14.2
Already downloaded: /Users/nahomie/Library/Caches/Homebrew/downloads/84abbc53ffbb8f36dc6dd856d9dcaa4d9b49a9d0f434a334b991f82c22fe63f4--libpq-14.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libpq/blobs/sha256:36b074f07ded99c1945dbcc26f54e45abeba0dbf34d16e63fb6ab16d371158ee
Already downloaded: /Users/nahomie/Library/Caches/Homebrew/downloads/88c1ec435b5360375c672305226528f5ffbfc88c4cb3b1bcf8697e43daa73e21--libpq--14.2.arm64_monterey.bottle.tar.gz
==> Reinstalling libpq 
==> Pouring libpq--14.2.arm64_monterey.bottle.tar.gz
==> Caveats
libpq is keg-only, which means it was not symlinked into /opt/homebrew,
because conflicts with postgres formula.

If you need to have libpq first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc

For compilers to find libpq you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/libpq/include"

For pkg-config to find libpq you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/libpq/lib/pkgconfig"

==> Summary

              

I am currently trying to run an application locally but running into some issues with postgreSql.

gem install pg gives me the following:

Fetching gem metadata from http://insecure.rails-assets.org/...
Fetching version metadata from http://insecure.rails-assets.org/..
Fetching gem metadata from http://insecure.rails-assets.org/...
Fetching gem metadata from https://rubygems.org/........
Fetching version metadata from http://insecure.rails-assets.org/..
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from http://insecure.rails-assets.org/..
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.4
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.5
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.5
Using globalid 0.3.6
Using activejob 4.2.5
Using mime-types 2.6.2
Using mail 2.6.3
Using actionmailer 4.2.5
Using active_link_to 1.0.3
Using activemodel 4.2.5
Using arel 6.0.3
Using activerecord 4.2.5
Using addressable 2.3.8
Using extlib 0.9.16
Using multi_json 1.11.2
Using autoparse 0.3.3
Using coderay 1.1.0
Using better_errors 2.1.1
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bootstrap_form 2.3.0
Using bundler 1.8.4
Using byebug 9.1.0 (was 8.2.0)
Using cancancan 1.13.1
Using chartkick 1.4.1
Using chunky_png 1.3.5
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.5
Using coffee-rails 4.1.0
Using concurrent-ruby 1.0.0
Using connection_pool 2.2.0
Using unf_ext 0.0.7.1
Using unf 0.1.4
Using domain_name 0.5.24
Using faker 1.6.1
Using multipart-post 2.0.0
Using faraday 0.9.2
Using ffi 1.9.10
Using font-awesome-rails 4.4.0.0
Using formatador 0.2.5
Using friendly_id 5.0.5
Using jwt 2.2.2
Using little-plugger 1.1.4
Using logging 2.0.0
Using memoist 0.12.0
Using signet 0.6.1
Using googleauth 0.4.2
Using launchy 2.4.3
Using retriable 1.4.1
Using google-api-client 0.8.6
Using groupdate 2.4.0
Using rb-fsevent 0.9.6
Using rb-inotify 0.9.5
Using listen 3.0.5
Using lumberjack 1.0.9
Using nenv 0.2.0
Using shellany 0.0.1
Using notiffany 0.0.8
Using method_source 0.8.2
Using slop 3.6.0
Using pry 0.10.3
Using guard 2.13.0
Using guard-compat 1.2.1
Using guard-minitest 2.4.4
Using tilt 2.0.1
Using haml 4.0.7
Using hashie 3.6.0
Using http-cookie 1.0.2
Using jbuilder 2.3.2
Using jquery-rails 4.0.5
Using mini_magick 4.2.7
Using multi_xml 0.5.5
Using netrc 0.10.3
Using oauth2 1.4.4
Using omniauth 1.9.1
Using omniauth-oauth2 1.7.0
Using omniauth-github 1.1.2
Using omniauth-google-oauth2 0.8.0
Using ruby-openid 2.7.0
Using rack-openid 1.3.1
Using omniauth-openid 1.0.1

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/username/.rbenv/versions/2.2.0/bin/ruby -r ./siteconf20220307-80476-1facihf.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
sh: /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config: No such file or directory
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=/Users/nahomie/.rbenv/versions/2.2.0/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-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

extconf failed, exit code 1

Gem files will remain installed in /Users/username/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/pg-0.18.4 for inspection.
Results logged to /Users/username/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-21/2.2.0-static/pg-0.18.4/gem_make.out
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.

gemfile

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  # gem 'byebug'
  gem 'byebug', '~> 9.1'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]


gem "haml"
gem "omniauth"
gem "omniauth-github"
gem "omniauth-google-oauth2", '~> 0.8.0'
gem "omniauth-openid"
gem "google-api-client"
gem "cancancan"
gem 'bootstrap_form'
gem 'friendly_id', '~> 5.0.0'
gem 'ransack'
gem 'rdiscount', require: 'tilt/rdiscount'
gem 'ruby_identicon'
gem 'sidekiq'
gem "refile", require: "refile/rails"
gem "refile-mini_magick"
gem 'simple_form'
gem 'active_link_to'
gem 'chartkick'
gem 'groupdate'
gem 'faker'
# gem 'skylight'

gem 'bundler', '>= 1.8.4'
source 'http://insecure.rails-assets.org' do
# source 'https://rails-assets.org' do
  gem 'rails-assets-bootstrap'
  gem 'rails-assets-jasny-bootstrap'
  gem 'rails-assets-handlebars'
  gem 'rails-assets-datatables'
  gem 'rails-assets-datatables-fixedcolumns'
  gem 'rails-assets-typeahead.js'
end
gem "font-awesome-rails"

# bring back removed support for respond_with
# gem 'responders', '~> 2.0'

group :production do
  gem 'rails_12factor'
  gem 'puma'
end

group :development do
  gem 'guard'
  gem 'guard-minitest'
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'quiet_assets'
  gem 'pry-rails'
end

ruby "2.2.0"

Steps I've tried:

bundle install

gem install pg

gem install pg -v '0.18.4

gem install pg 0.18.4

I also tried to modify the pg in the gemfile with the exact version that was required and then running bundle install

When I tried to run brew install libpq

==> Downloading https://ghcr.io/v2/homebrew/core/libpq/manifests/14.2
Already downloaded: /Users/nahomie/Library/Caches/Homebrew/downloads/84abbc53ffbb8f36dc6dd856d9dcaa4d9b49a9d0f434a334b991f82c22fe63f4--libpq-14.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libpq/blobs/sha256:36b074f07ded99c1945dbcc26f54e45abeba0dbf34d16e63fb6ab16d371158ee
Already downloaded: /Users/nahomie/Library/Caches/Homebrew/downloads/88c1ec435b5360375c672305226528f5ffbfc88c4cb3b1bcf8697e43daa73e21--libpq--14.2.arm64_monterey.bottle.tar.gz
==> Reinstalling libpq 
==> Pouring libpq--14.2.arm64_monterey.bottle.tar.gz
==> Caveats
libpq is keg-only, which means it was not symlinked into /opt/homebrew,
because conflicts with postgres formula.

If you need to have libpq first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc

For compilers to find libpq you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/libpq/include"

For pkg-config to find libpq you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/libpq/lib/pkgconfig"

==> Summary
????  /opt/homebrew/Cellar/libpq/14.2: 2,336 files, 28.2MB
==> Running `brew cleanup libpq`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁把谁当真 2025-01-19 11:27:59

您需要安装libpq

步骤

brew install libpq

通过运行以下命令找到 libpq 版本

brew info libpq

然后安装 pg

gem install pg — — with-pg-config=/usr/local/Cellar/libpq/[VERSION FROM ABOVE COMMAND]/bin/pg_config

希望这可以解决您的问题。
谢谢

You need to install libpq.

STEPS

brew install libpq

Find the libpq version by running below command

brew info libpq

Then install pg with

gem install pg — — with-pg-config=/usr/local/Cellar/libpq/[VERSION FROM ABOVE COMMAND]/bin/pg_config

Hope This solves your Problem.
Thank You

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文