由于gem pg(0.18.4),我无法进行捆绑安装 [英] I can't do bundle install because of gem pg(0.18.4)

查看:73
本文介绍了由于gem pg(0.18.4),我无法进行捆绑安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS上使用ec2,并尝试部署我的Rails应用程序.我成功git将我的应用程序克隆到了ec2-user上,然后尝试进行捆绑安装,但由于gem pg而无法正常工作.我不知道为什么我不能安装捆绑软件.我在堆栈溢出上尝试了几种解决方案,但是什么都没用.需要您的帮助.

I am using ec2 on aws and trying to deploy my rails app. I successfully git cloned my app to my ec2-user then tried bundle install but which didn't work because of gem pg. I don't know why I can't do bundle install. I tried several solutions on stack overflow but anything didn't work. need your help.

Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Rubygems 2.0.14.1 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Using rake 11.1.1
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types 2.99.1
Using arel 6.0.3
Using execjs 2.6.0
Using debug_inspector 0.0.2
Using sass 3.4.21
Using byebug 8.2.2
Using net-ssh 3.1.0
Using coffee-script-source 1.10.0
Using thor 0.19.1
Using concurrent-ruby 1.0.1
Using multi_json 1.11.2
Installing pg 0.18.4 with native extensions

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

    /usr/bin/ruby2.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}/lib64
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby2.0
    --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}/


Gem files will remain installed in /home/ec2-user/.gem/ruby/2.0/gems/pg-0.18.4 for inspection.
Results logged to /home/ec2-user/.gem/ruby/2.0/gems/pg-0.18.4/ext/gem_make.out
Using bundler 1.11.2
Using tilt 2.0.2
Using spring 1.6.4
Installing sqlite3 1.3.11 with native extensions

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

    /usr/bin/ruby2.0 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
*** 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}/lib64
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby2.0
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/


Gem files will remain installed in /home/ec2-user/.gem/ruby/2.0/gems/sqlite3-1.3.11 for inspection.
Results logged to /home/ec2-user/.gem/ruby/2.0/gems/sqlite3-1.3.11/ext/sqlite3/gem_make.out
Using rdoc 4.2.2
Using tzinfo 1.2.2
Using nokogiri 1.6.7.2
Using rack-test 0.6.3
Using mail 2.6.3
Using autoprefixer-rails 6.3.3.1
Using uglifier 2.7.2
Using binding_of_caller 0.7.2
Using net-scp 1.2.1
Using coffee-script 2.4.1
Using sprockets 3.5.2
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.

我的gem文件在

source 'https://rubygems.org'

ruby '2.0.0'
gem 'rails_12factor', group: :production
gem 'bootstrap-sass'
gem 'rails', '4.2.5.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'capistrano', '~> 3.4.0'

group :development, :test do
    gem 'sqlite3'
end

group :development, :test do
    gem 'pg'
end 


group :development, :test do
  gem 'byebug'
end

group :development do

  gem 'web-console', '~> 2.0'

  gem 'spring'
end

推荐答案

该错误在堆栈跟踪中可见:

The error is visible in the stack trace:

Can't find the 'libpq-fe.h header

您没有构建PG适配器所需的libpq标头.确保已安装PostgreSQL和dev依赖项(libpq-dev软件包).

You don't have libpq headers, required for building the PG adapter. Make sure you installed PostgreSQL and the dev dependencies (the libpq-dev package).

此外,您需要清理您的Gemfile.您有3个等效的group :development, :test do声明.

Also, you need to cleanup your Gemfile. You have 3 equivalent group :development, :test do declarations.

此外,您将Sqlite3和PG gem都导入到同一环境中.决定您的数据库,并只使用其中之一.

Plus, you import both the Sqlite3 and PG gems in the same envs. Take a decision about your database, and use only one of them.

最后但并非最不重要的一点是,您没有声明要用于生产的数据库,因此部署到生产将失败.

Last but not least, you have no database declared for production, hence your deployment to production will fail.

这篇关于由于gem pg(0.18.4),我无法进行捆绑安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆