简体   繁体   English

安装pg(0.18.2)时发生错误,并且Bundler无法继续

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

Following Tony Coconate's Rails + Ember.js (with the Ember CLI) tutorial, we are trying to create a new Rails API. 遵循Tony Coconate的Rails + Ember.js(带有Ember CLI)教程之后,我们尝试创建一个新的Rails API。

When we run rails new api -T -d postgresql , we get the following error message: 当我们运行rails new api -T -d postgresql ,我们收到以下错误消息:

An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.

This is what the Gemfile file looks like: 这就是Gemfile文件的样子:

source "https://rubygems.org"

gem "rails", "4.2.1"

gem "activeadmin", github: "gregbell/active_admin" # Until it"s 1.0.0
gem "coffee-rails", "~> 4.0.0"
gem "devise"
gem "grape"
gem "grape-active_model_serializers"
gem "grape-swagger-rails"
gem "jquery-rails"
gem "pg"
gem "rack-cors", require: "rack/cors"
gem "sass-rails", "~> 4.0.3"
gem "uglifier", ">= 1.3.0"

group :development do
  gem "better_errors"
  gem "meta_request"
  gem "quiet_assets"
  gem "spring"
end

group :development, :test do
  gem "capybara"
  gem "capybara-screenshot"
  gem "database_cleaner"
  gem "factory_girl_rails"
  gem "faker"
  gem "poltergeist"
  gem "pry-nav"
  gem "pry-rails"
  gem "pry-stack_explorer"
  gem "pry-theme"
  gem "rspec-rails"
  gem "rubocop"
  gem "shoulda-matchers"
  gem "spring-commands-rspec"
end

When we run bundle install , we get the following error message: 运行bundle install ,出现以下错误消息:

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

    /Users/user_name/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150629-73521-9m0ocx.rb 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=/Users/user_name/.rvm/rubies/ruby-2.2.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

extconf failed, exit code 1

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

When we run gem install pg -v '0.18.2' , we also get an error: 当我们运行gem install pg -v '0.18.2' ,我们还会得到一个错误:

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

    /Users/user_name/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150629-73553-uaymt5.rb 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=/Users/user_name/.rvm/rubies/ruby-2.2.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

extconf failed, exit code 1

Gem files will remain installed in /Users/user_name/.rvm/gems/ruby-2.2.1/gems/pg-0.18.2 for inspection.
Results logged to /Users/user_name/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/pg-0.18.2/gem_make.out

Any idea of what is wrong, and most importantly, how we can fix it? 关于错误的任何想法,最重要的是,我们如何解决它?

Ok, so I found the solution to my problem. 好的,所以我找到了解决问题的方法。

First, I installed the pg gem with homebrew, as explained here : 首先,我使用自制软件安装了pg gem, 如下所示

brew install postgres

Then, I could not start the rails server, so I followed this solution and ran: 然后,我无法启动Rails服务器,因此我遵循了此解决方案并运行:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Now, everything is working. 现在,一切正常。

It's an error showing that bundler cannot access the psql binary 显示错误,表明捆绑程序无法访问psql二进制文件

You can install postgresql , as suggested in the other answer. 您可以按照其他答案中的建议安装postgresql However, if you are using the Postgres.app from http://postgresapp.com/ , then you just have to set your $PATH by adding the following line in your ~/.bash_profile file: 但是,如果您正在使用http://postgresapp.com/中Postgres.app ,则只需在~/.bash_profile文件中添加以下行来设置$PATH

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin

More info: http://postgresapp.com/documentation/cli-tools.html 更多信息: http : //postgresapp.com/documentation/cli-tools.html

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

相关问题 Ubuntu 14.04-安装pg(0.18.2)时发生错误,并且Bundler无法继续 - Ubuntu 14.04 - An error occurred while installing pg (0.18.2), and Bundler cannot continue 安装 pg (0.15.1) 时出错,Bundler 无法继续 - An error occurred while installing pg (0.15.1), 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 安装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 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