2011-09-04 12 views
38

Rails 3.1にアップグレードしたばかりで、Herokuにデプロイしようとした最初のアプリでPostgresアダプタに関する問題が発生しました。私はHerokuのにアプリをプッシュすることができるよしかし、私は、データベースを移行しようとすると、その後、私は次のエラーを取得:Rails 3.1 - Herokuにプッシュする - postgres adapterをインストールする際のエラー?

Herokuのすくいデシベル:私は彼らの提案私が手をインストールしようとすると

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 

私は私が手宝石PGインストールしてみてください:私は現在、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

どのようにRailsのためのセットアップのPostgreSQLをすると、Herokuの HTTPを実行したときに

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

魅力のように働いていた:私はとき

問題は、私の新しいRailsのために離れて3.1アプリを行ってきました.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(Debianの/ Ubuntuの):

があなたの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

クールなええ、私は2番目のことをやめました。 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またはpostgres-prを使用しているため)、gem 'pg'行をGemfileのproductionというグループに入れてから、bundle install --without productionをローカルに置くことができます。

1

最新の情報:これは、ローカルに異なるバージョンのpg gemと関係がありました。

私はすでにプロダクショングループにpgを持っていました(私はローカルでsqlliteを実行しています)が、Herokuはまだプークしていました。 // robdodson:私はその後、heroku run rake db:migrate

関連する問題