2011-09-04 2 views
38

난 그냥 레일 3.1로 업그레이 드하고 Heroku에 배포하려 애쓰는 첫 번째 애플 리케이션은 Postgres 어댑터와 관련된 문제가 발생했습니다. 나는 Heroku가 앱을 밀어 수 있어요하지만 나는 다음과 같은 오류가 데이터베이스를 마이그레이션 할 때 다음 :Rails 3.1 - Heroku로 푸시 - Postgres 어댑터를 설치하는 중 오류가 발생 했습니까?

에게 Heroku 레이크 dB : 나는 그들의 내가 얻을 설치 제안하려고 할 때

rake aborted! 
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` 
(pg is not part of the bundle. Add it to Gemfile.) 
Tasks: TOP => db:migrate => db:load_config 
(See full trace by running task with --trace) 

마이그레이션 : 이미 이상한 것 같다 ... 그래서 정확히 어떤 보석이 나는 그들이 내가 설치해야합니다 말을하지 무엇을하면 작업이 물건을 얻기 위해 설치해야

ERROR: Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in any repository 
ERROR: Possible alternatives: activerecord-postgis-adapter, activerecord-jdbcpostgresql-adapter, activerecord-postgresql-cursors, activerecord-jdbcmysql-adapter, activerecord-jdbcmssql-adapter 

? 나는 보석 페이지를 설치하려고하면

내가 얻을 : 나는 현재 sqlite3를 사용하고

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

/Users/jerometufte/.rvm/rubies/ruby-1.9.2-p180/bin/ruby 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 
    ... 

. 어떤 도움이라도 대단히 감사합니다.

+0

heroku run rake db:migrate을 실행했을 때 어떻게 레일 및 Heroku가 HTTP에 대한 설정의 PostgreSQL을 : //로 robdodson .me/blog/2012/04/27/how-to-setup-postgresql-for-rails-and-heroku/ –

답변

41

옵션 1 :

Gemfilepg을 추가하지만 로컬로 설치하려고 건너 뜁니다.

$ cat Gemfile 
... 
group :production do 
    # gems specifically for Heroku go here 
    gem "pg" 
end 

# Skip attempting to install the pg gem 
$ bundle install --without production 

옵션 2 (데비안/우분투) :

Gemfilepg을 추가하지만, 먼저 필수 구성 요소를 설치합니다.

$ cat Gemfile 
... 
group :production do 
    # gems specifically for Heroku go here 
    gem "pg" 
end 

# Install the pg gem's dependencies first 
$ sudo apt-get install libpq-dev 
# Then install the pg gem along with all the other gems 
$ bundle install 
+0

쿨 나는 두 번째를 끝내었다. 로컬로 postgresql을 유지하는 것이 짜증이 든다면 아마 그 결정을 후회하지 않기를 바랄 것입니다. – tuddy

+0

'README'에 의견을 추가하십시오. – yfeldblum

4

확실히 Heroku 용 Gemfile에 pg가 필요합니다.

로컬로 전송되는 오류 : postgres가 설치되어 있는지 확인하고 gem install pq -- --with-pg-config=[path to wherever your pg-config binary is]을 실행 한 다음 번들 설치를 실행하십시오.

또는 로컬 데이터베이스가 잘 작동하는 경우 (중 당신이 sqlite가 또는 포스트 그레스 - 홍보를 사용하기 때문에), 당신은 다음 그룹이라는 생산에 Gemfile에 bundle install --without productiongem 'pg' 라인을 로컬로 둘 수 있었다.

1

최신 정보 : 다른 버전의 pg 보석과 관련이 있습니다.

나는 프로덕션 그룹 (이미 sqllite를 로컬로 실행)에 pg를 가지고 있었지만 Heroku는 여전히 푸킹하고있었습니다. I 때

이 문제는 나의 새로운 레일 멀리 3.1 응용 프로그램을했다 :

rm Gemfile.lock 
touch Gemfile 
bundle install 
git add . 
git commit -am "wiped Gemfile.lock re-ran bundle install" 
git push heroku master 

이 마법처럼 일을 그때

관련 문제