简体   繁体   English

安装 pg (0.15.1) 时出错,Bundler 无法继续

[英]An error occurred while installing pg (0.15.1), and Bundler cannot continue

I am fairly new to ruby and while going through the railstutorial.org, I ran into an issue.我对 ruby​​ 相当陌生,在浏览 railstutorial.org 时,我遇到了一个问题。 When I attempt to bundle install my ruby application with 'bundle install --without production', I get:当我尝试使用“bundle install --without production”捆绑安装我的 ruby​​ 应用程序时,我得到:

Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.41
Using activesupport 4.0.8
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.0.8
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.0.8
Using activemodel 4.0.8
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using activerecord 4.0.8
Using bundler 1.7.3
Using mini_portile 0.6.0
Using nokogiri 1.6.3.1
Using xpath 2.0.0
Using capybara 2.1.0
Using ffi 1.9.6
Using childprocess 0.5.5
Using coffee-script-source 1.8.0
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.0.8
Using coffee-rails 4.0.1
Using diff-lcs 1.2.5
Using hike 1.2.3
Using jbuilder 1.0.2
Using jquery-rails 3.0.4
Using json 1.8.1

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/bryansaxon/.rvm/rubies/ruby-2.0.0-p576/bin/ruby 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
    --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/bryansaxon/.rvm/rubies/ruby-2.0.0-p576/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config


Gem files will remain installed in /Users/bryansaxon/.rvm/gems/ruby-2.0.0-        
p576@railstutorial_rails_4_0/gems/pg-0.15.1 for inspection.
Results logged to /Users/bryansaxon/.rvm/gems/ruby-2.0.0-p576@railstutorial_rails_4_0/gems/pg- 
0.15.1/ext/gem_make.out
An error occurred while installing pg (0.15.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.15.1'` succeeds before bundling.

Then when I try to 'gem install pg -v '0.15.1'', I get:然后当我尝试 'gem install pg -v '0.15.1'' 时,我得到:

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

/Users/bryansaxon/.rvm/rubies/ruby-2.0.0-p576/bin/ruby 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
    --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/bryansaxon/.rvm/rubies/ruby-2.0.0-p576/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config


Gem files will remain installed in /Users/bryansaxon/.rvm/gems/ruby-2.0.0-    
p576@railstutorial_rails_4_0/gems/pg-0.15.1 for inspection.
Results logged to /Users/bryansaxon/.rvm/gems/ruby-2.0.0-p576@railstutorial_rails_4_0/gems/pg-
0.15.1/ext/gem_make.out

Then I tried to install 'gem install pg -v '0.15.1' --with-pg_config' and got:然后我尝试安装 'gem install pg -v '0.15.1' --with-pg_config' 并得到:

ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-pg_config

Now I am stuck and not sure how to fix the issue.现在我被卡住了,不知道如何解决这个问题。 Have tried numerous methods through other posts outlying the same issue but nothing seems to work.通过与同一问题无关的其他帖子尝试了多种方法,但似乎没有任何效果。 Any help would be much appreciated!任何帮助将非常感激! I am on a Mac running Yosemite.我在运行 Yosemite 的 Mac 上。

Here is my Gemfile:这是我的 Gemfile:

source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.8'
gem 'pg', '0.15.1'

group :development, :test do
  gem 'rspec-rails', '2.13.1'
end

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
end

gem 'sass-rails', '4.0.3'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'rails_12factor', '0.0.2'
end

Since gem 'pg', '0.15.1' is not in group :production , bundler try ti install it even if you run it with --without production option.由于gem 'pg', '0.15.1'不在group :production ,即使您使用--without production选项运行它,bundler 也会尝试安装它。 Thus, you have 2 options:因此,您有 2 个选择:

  • install postgresql first and use it in development首先安装 postgresql 并在开发中使用它
  • move gem "pg" to production group, and use different database in development.gem "pg"移至生产组,并在开发中使用不同的数据库。 For example - gem "sqlite3"例如 - gem "sqlite3"

尝试使用'>=0.15.1'而不是'0.15.1'

Another workaround would be:另一种解决方法是:

sudo apt install postgresql-contrib libpq-dev

By installing this dependency, you'll be able to bundle your application.通过安装此依赖项,您将能够捆绑您的应用程序。 PostgreSQL should be installed on the machine as well. PostgreSQL 也应该安装在机器上。 If you haven't done so:如果你还没有这样做:

apt update

apt full-upgrade

apt install postgresql postgresql-client

PostgreSQL won't run properly if your firewall prohibits access on port 5432.如果您的防火墙禁止访问端口 5432,PostgreSQL 将无法正常运行。

apt install ufw

If you're remote... Allow 22 so you don't get logged out.如果你是远程...允许 22 这样你就不会被注销。

ufw allow 22

ufw allow 5432

ufw enable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 安装pg(0.15.1)时发生错误,Bundler无法继续 - error occurred while installing pg (0.15.1), and Bundler cannot continue 安装pg(1.1.4)时发生错误,并且Bundler无法继续 - An error occurred while installing pg (1.1.4), and Bundler cannot continue 安装pg(1.2.1)时出错,Bundler无法继续 - An error occurred while installing pg (1.2.1), and Bundler cannot continue 安装pg(1.2.3)时出错,Bundler无法继续 - An error occurred while installing pg (1.2.3), and Bundler cannot continue 安装pg(0.18.2)时发生错误,并且Bundler无法继续 - An error occurred while installing pg (0.18.2), and Bundler cannot continue 安装 pg (0.18.4) 时出错,Bundler 无法继续 - An error occurred while installing pg (0.18.4), and Bundler cannot continue 安装pg(0.19.0)时发生错误,Bundler无法继续 - An error occurred while installing pg (0.19.0), and Bundler cannot continue 安装 pg (0.17.1) 时出错,Bundler 无法继续 - An error occurred while installing pg (0.17.1), and Bundler cannot continue Ubuntu 14.04-安装pg(0.18.2)时发生错误,并且Bundler无法继续 - Ubuntu 14.04 - An error occurred while installing pg (0.18.2), and Bundler cannot continue Rails - 安装 pg (1.1.3) 时出现 Gem 错误,并且 Bundler 无法继续 - Rails - Gem Error while installing pg (1.1.3), and Bundler cannot continue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM