Rails 3.1-pchać się do Heroku - błędy w instalacji adaptera postgres?
Właśnie zaktualizowałem Rails 3.1 i pierwsza aplikacja, którą próbowałem wdrożyć do Heroku napotkała problem związany z adapterem Postgres. Jestem w stanie wcisnąć aplikację do heroku, ale wtedy, gdy próbuję przenieść bazę danych dostaję następujący błąd:
Heroku rake db: migrate
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)
Kiedy wypróbuję ich sugerowaną instalację dostaję:
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
Co już wydaje się dziwne... więc jaki dokładnie klejnot powinienem zainstalować, aby to działało, jeśli nie to, co mówią, powinienem zainstalować??
Kiedy próbuję zainstalować gem pg dostaję:
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
...
Obecnie używam SQLite3. Każda pomoc bardzo doceniana, to mnie dziwi.
3 answers
Wariant 1:
Dodaj pg
do swojego Gemfile
, ale pomiń próby zainstalowania go lokalnie.
$ 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
Opcja 2 (Debian / Ubuntu):
Dodaj pg
do swojego Gemfile
, ale najpierw zainstaluj wymagania wstępne.
$ 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
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-09-04 03:33:31
Zdecydowanie potrzebujesz pg w Gemfile dla Heroku.
O błędzie, który pojawia się lokalnie: upewnij się, że masz zainstalowany postgres, Uruchom gem install pq -- --with-pg-config=[path to wherever your pg-config binary is]
, a następnie zainstaluj pakiet.
Alternatywnie, jeśli Twoja lokalna baza danych działa poprawnie (ponieważ używasz sqlite lub postgres-pr), możesz umieścić linię gem 'pg'
w pliku Gemfile w grupie o nazwie production, a następnie bundle install --without production
lokalnie.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-09-04 02:27:51
Bardziej aktualne informacje: miało to coś wspólnego z inną wersją PG gem lokalnie.
Miałem już pg w grupie produkcyjnej( prowadzę SQLLite lokalnie), ale Heroku wciąż rzygał.
Problem zniknął dla mojej nowej aplikacji Rails 3.1, gdy:
rm Gemfile.lock
touch Gemfile
bundle install
git add .
git commit -am "wiped Gemfile.lock re-ran bundle install"
git push heroku master
Zadziałało jak urok, kiedy pobiegłem heroku run rake db:migrate
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-04-10 07:49:08