简体   繁体   English

为什么不能在AWS Elastic Beanstalk中安装pg gem?

[英]Why can't the pg gem be installed in AWS Elastic Beanstalk?

I am deploying a simple application to AWS Elastic Beanstalk. 我正在向AWS Elastic Beanstalk部署一个简单的应用程序。 However, the moment I put gem 'pg' in the Gemfile and push these to Elastic Beanstalk. 但是,我将Gemfile gem 'pg'放入Gemfile并将其推送到Elastic Beanstalk的那一刻。 I get the following errors in my logs: 我的日志中出现以下错误:

-------------------------------------
/var/log/eb-tools.log
-------------------------------------
Installing actionpack (4.0.1) 
Installing mime-types (1.25) 
Installing polyglot (0.3.3) 
Installing treetop (1.4.15) 
Installing mail (2.5.4) 
Installing actionmailer (4.0.1) 
Installing activemodel (4.0.1) 
Installing activerecord-deprecated_finders (1.0.3) 
Installing arel (4.0.1) 
Installing activerecord (4.0.1) 
Installing coffee-script-source (1.6.3) 
Installing execjs (2.0.2) 
Installing coffee-script (2.2.0) 
Installing thor (0.18.1) 
Installing railties (4.0.1) 
Installing coffee-rails (4.0.1) 
Installing hike (1.2.3) 
Installing jbuilder (1.5.2) 
Installing jquery-rails (3.0.4) 
Using json (1.8.1) 
Installing pg (0.17.0) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9 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}/
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby1.9
    --with-pg
    --without-pg
    --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 /usr/share/ruby/1.9/gems/1.9.1/gems/pg-0.17.0 for inspection.
Results logged to /usr/share/ruby/1.9/gems/1.9.1/gems/pg-0.17.0/ext/gem_make.out
An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.
ERROR: bundle install failed!

2013-11-17 14:10:03,371 [ERROR] (8302 MainThread) [directoryHooksExecutor.py-34] [root directoryHooksExecutor error] Script failed with returncode 1
2013-11-17 14:10:03,499 [INFO] (8269 MainThread) [command.py-130] [root command execute] Command returned: (code: 1, stdout: Error occurred during build: Command hooks failed
, stderr: None)
....

I get no errors locally. 我在本地没有错误。

Quite some time ago, I remember encountering this problem on my other Ubuntu boxes. 很久以前,我记得在我的其他Ubuntu盒子上遇到这个问题。 Apparently, one needs to install additional libraries via sudo apt-get install ruby-dev build-essential or sudo apt-get install postgresql-client libpq5 libpq-dev . 显然,需要通过sudo apt-get install ruby-dev build-essentialsudo apt-get install postgresql-client libpq5 libpq-dev安装额外的库。 I would give it a shot, but On AWS Elastic Beanstalk, I am not so sure how to do this. 我会试一试,但在AWS Elastic Beanstalk上,我不太清楚如何做到这一点。

In .ebextensions/packages.config : .ebextensions/packages.config

packages:
  yum:
    postgresql-devel: []

This will ensure any new instances will have this lib installed 这将确保任何新实例都安装此lib

add

packages:
  yum:
    postgresql93-devel: []

In .ebextensions/packages.config .ebextensions/packages.config

packages:
  yum:
    postgresql-devel: []

The important thing to note is that you need to set postgresql-devel to match the lib for your postgresql version. 需要注意重要一点是,您需要设置postgresql-devel以匹配postgresql版本的lib。 eg, if you have postgresql 9.4.5 you need to install a postgresql-develXX. 例如,如果你有postgresql 9.4.5你需要安装postgresql-develXX。

Using yum list you will be able to identify the correct lib. 使用yum list您将能够识别正确的lib。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM