Set up the pg gem - postgresql in development

0

I'm using Cloud9 on AWS in development and EB for deployment.
Found a lot of old stuff, but having problem to install pg gem.

  1. started with codestar, using ruby on rails app
  2. for now with elastic beanstalk
  3. using IDE Cloud9
  4. added RDS Postgresql for the EB
  5. installed all gems needed, except the pg gem
  • postgresql set in database config for dev and production

  • postgresql93-devel added in the packages.conf

  • tried to add libpq-dev - NOT WORKING (?)

sudo yum install libpq-dev
  • this worked (not sure if this is correct)
sudo yum install postgresql-libs

Still error when installing the gem:


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

_current directory: /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/pg-0.21.0/ext_  

/usr/local/rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20171207-7455-1v09v4h.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.

Any new ideas how to setup Postgresql with Cloud9 on AWS?

Edited by: mikesk on Dec 7, 2017 2:50 AM

mikesk
질문됨 6년 전4023회 조회
4개 답변
1

I just ran into this myself, it turns out the package you need is called postgresql-devel on RHEL systems. Try:

sudo yum install postgresql-devel

I agree this should work out of the box. Until we are actually able to set our own base images, or AWS fixes this, though, that should suffice.

ckeele
답변함 6년 전
  • This answer worked for me when needing to install the Python package psycopg2 to a Cloud9 instance and originally receiving an error indicating pg_config could not be found.

0

As of February 27, 2018, the above solution is not working on Amazon Linux Cloud9. Not sure whether Amazon updated its AMI so that it no longer functions or what.

The pg_config file in /usr/bin references postgresql-9.6, but all of the components necessary to compile the pg gem for pg-9.6 are not installed when booting up the AMI for the first time. What got it working for me was the following:

sudo yum install postgresql96 postgresql96-server postgresql96-libs postgresql96-contrib postgresql96-devel
stnagy
답변함 6년 전
0

Thanks very much for posting the instructions. I'd like to ask if anyone knows how to start the postgresql service after installing postgresql on AWS Cloud 9.

I have tried to run sudo service postgresql start without much success.

Similarly, I've also tried to run the following without much success

systemctl enable postgresql-9.6.service
systemctl start postgresql-9.6.service

Any assistance would be much appreciated!

mikeqz
답변함 6년 전
0

You can follow the instructions on this article: https://medium.com/@floodfx/setting-up-postgres-on-cloud9-ide-720e5b879154

sudo yum install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs

sudo service postgresql initdb

flush
답변함 5년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠