I am having trouble pushing my rails app to Heroku/getting the 'pg' gem to install?

拥有回忆 提交于 2020-01-06 01:27:25

问题


Originally I couldn't push my rails 4 app to heroku because my database was sqlite, and so now I have been trying to install the Postgresql gem ('pg') but I am not having any luck. This is the error message I get in my terminal after running bundle install:

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 ***

After running
gem install pg -v '0.17.1' -–with-pg-config

I get this error in my terminal:

ERROR:  While executing gem ... (Gem::Requirement::BadRequirementError)
 Illformed requirement ["0.17.1--with-pg_config"]
/project$ gem install pg -v '0.17.1'--with-pg-config
ERROR:  Could not find a valid gem 'pg' (= 0.17.1.pre..pre.with.pre.pg.pre.config) in   

any repository
ERROR:  Possible alternatives: pg

Thanks for the help.


回答1:


If you don't have postgres installed, you may want to go with:

sudo apt-get install postgresql
sudo apt-get install libpq-dev

following by gem install pg and bundle.

If you do have postgres installed and running gem install pg doesn't work, you have to run which pg_config to get the path to your pg_config, and run gem install pg -- --with-pg-config= output_from_previous_command.



来源:https://stackoverflow.com/questions/25714338/i-am-having-trouble-pushing-my-rails-app-to-heroku-getting-the-pg-gem-to-insta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!