2012-02-13 16 views
7

Ok, więc mam aplikacji Rails, że jestem próby uruchomienia migracje on a PostgreSQL db i ja zwykle korzystam z mysql i wszystko jest dobrze, ale gdy uruchamiam polecenie uzyskać torake db: migrować nie działa na moim PostgreSQL db

rake db:migrate 
(in /Users/tamer/Sites/my_app) 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487: [BUG] Segmentation fault 
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0] 

-- control frame ---------- 
c:0058 p:---- s:0215 b:0215 l:000214 d:000214 CFUNC :exec 
c:0057 p:0040 s:0211 b:0211 l:000191 d:000210 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter 
c:0056 p:0005 s:0208 b:0208 l:000198 d:000207 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.r 
c:0055 p:0032 s:0206 b:0206 l:000205 d:000205 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21 
c:0054 p:0052 s:0199 b:0199 l:000198 d:000198 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.r 
c:0053 p:0018 s:0192 b:0192 l:000191 d:000191 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter 
c:0052 p:0013 s:0187 b:0187 l:000186 d:000186 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter 
c:0051 p:0011 s:0184 b:0184 l:000183 d:000183 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter 
c:0050 p:0136 s:0180 b:0180 l:000179 d:000179 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter 
c:0049 p:0131 s:0177 b:0177 l:000176 d:000176 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter 
c:0048 p:0054 s:0174 b:0174 l:000173 d:000173 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter 
c:0047 p:---- s:0167 b:0167 l:000166 d:000166 FINISH 
c:0046 p:---- s:0165 b:0165 l:000164 d:000164 CFUNC :new 
c:0045 p:0186 s:0158 b:0158 l:000157 d:000157 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter 
c:0044 p:0045 s:0149 b:0149 l:000148 d:000148 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0043 p:0011 s:0146 b:0146 l:000145 d:000145 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0042 p:0048 s:0142 b:0142 l:000128 d:000141 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0041 p:---- s:0139 b:0139 l:000138 d:000138 FINISH 
c:0040 p:---- s:0137 b:0137 l:000136 d:000136 CFUNC :loop 
c:0039 p:0009 s:0134 b:0134 l:000128 d:000133 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0038 p:0019 s:0132 b:0132 l:000131 d:000131 METHOD /Users/tamer/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201 
c:0037 p:0013 s:0129 b:0129 l:000128 d:000128 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0036 p:0030 s:0126 b:l:000122 d:000122 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0035 p:0033 s:0120 b:0120 l:000119 d:000119 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0034 p:0018 s:0115 b:0115 l:000114 d:000114 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0033 p:0011 s:0112 b:0112 l:000111 d:000111 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio 
c:0032 p:0020 s:0109 b:0109 l:000108 d:000108 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:486 
c:0031 p:---- s:0103 b:0103 l:000102 d:000102 FINISH 
c:0030 p:---- s:0101 b:0101 l:000100 d:000100 CFUNC :new 
c:0029 p:0020 s:0095 b:0095 l:000094 d:000094 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:433 
c:0028 p:0083 s:0090 b:0090 l:000089 d:000089 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:415 
c:0027 p:0102 s:0085 b:0085 l:000d58 d:000084 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:142 
c:0026 p:---- s:0083 b:0083 l:000082 d:000082 FINISH 
c:0025 p:---- s:0081 b:0081 l:000080 d:000080 CFUNC :call 
c:0024 p:0043 s:0076 b:0076 l:000067 d:000075 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:636 
c:0023 p:---- s:0073 b:0073 l:000072 d:000072 FINISH 
c:0022 p:---- s:0071 b:0071 l:000070 d:000070 CFUNC :each 
c:0021 p:0171 s:0068 b:0068 l:000067 d:000067 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:631 
c:0020 p:0110 s:0064 b:0064 l:000058 d:000063 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:597 
c:0019 p:0019 s:0062 b:0062 l:000061 d:000061 METHOD /Users/tamer/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201 
c:0018 p:0033 s:0059 b:0059 l:000058 d:000058 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:590 
c:0017 p:0048 s:0053 b:0053 l:000052 d:000052 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:583 
c:0016 p:0045 s:0048 b:0048 l:000047 d:000047 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2051 
c:0015 p:0012 s:0041 b:0041 l:000026 d:000040 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2029 
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH 
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC :each 
c:0012 p:0069 s:0033 b:0033 l:000026 d:000032 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2029 
c:0011 p:0009 s:0031 b:0031 l:000030 d:000030 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/airbrake-3.0.9/lib/airbrake/rake_handler.rb:33 
c:0010 p:0011 s:0027 b:0027 l:000026 d:000026 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2023 
c:0009 p:0029 s:0024 b:0024 l:000017 d:000023 BLOCK /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2001 
c:0008 p:0009 s:0022 b:0022 l:000021 d:000021 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2068 
c:0007 p:0011 s:0018 b:0018 l:000017 d:000017 METHOD /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:1998 
c:0006 p:0036 s:0015 b:0015 l:000014 d:000014 TOP /Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/bin/rake:31 
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH 
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :load 
c:0003 p:0127 s:0007 b:0007 l:0014e8 d:000f40 EVAL /Users/tamer/.rvm/gems/[email protected]_app/bin/rake:19 
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH 
c:0001 p:0000 s:0002 b:0002 l:0014e8 d:0014e8 TOP 
--------------------------- 
-- Ruby level backtrace information ---------------------------------------- 
/Users/tamer/.rvm/gems/[email protected]_app/bin/rake:19:in `<main>' 
/Users/tamer/.rvm/gems/[email protected]_app/bin/rake:19:in `load' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/bin/rake:31:in `<top (required)>' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:1998:in `run' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/airbrake-3.0.9/lib/airbrake/rake_handler.rb:33:in `standard_exception_handling' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2029:in `each' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' 
/Users/tamer/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:631:in `execute' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:631:in `each' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/rake-0.8.7/lib/rake.rb:636:in `call' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:415:in `migrate' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:433:in `up' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:433:in `new' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:486:in `initialize' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:316:in `retrieve_connection' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:93:in `connection' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `checkout' 
/Users/tamer/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `block in checkout' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `loop' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `block (2 levels) in checkout' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `checkout_new_connection' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:228:in `new_connection' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `postgresql_connection' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `new' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:228:in `initialize' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:939:in `connect' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:956:in `configure_connection' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:278:in `set_standard_conforming_strings' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:699:in `client_min_messages' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:483:in `query' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:195:in `log' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:197:in `block in log' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487:in `block in query' 
/Users/tamer/.rvm/gems/[email protected]_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487:in `exec' 

-- C level backtrace information ------------------------------------------- 

[NOTE] 
You may have encountered a bug in the Ruby interpreter or extension libraries. 
Bug reports are welcome. 
For details: http://www.ruby-lang.org/bugreport.html 

Abort trap 

Mój plik database.yml wygląda to

development: 
encoding: unicode 
adapter: postgresql 
username: postgres 
port: 5432 
host: localhost 
database: test 
password: password 

jakiś pomysł co robię wrong..these są poprawne poświadczenia bo conntect do tego PostgreSQL db za pomocą narzędzia GUI z tymi creds

użyłem tego link zainstalować gem pg

+1

sam problem, jeśli uruchomić? $ pakiet exec rake db: migrate –

+0

Właśnie dostałem dokładnie ten sam problem. Jednak: Linux, Ruby 1.9.3p0 i AR 3.2.1 –

Odpowiedz

0

chciałbym spróbować wykonać następujące czynności:

  1. usunąć wiersz gospodarza
  2. zmiana bieg wiązki
  3. zmienić nazwę bazy danych, tak aby upewnić się jej świeży
  4. prowadzony rake db: create
  5. prowadzony rake db: migrować

Mam problemy, w których moja pg gem nie jest odpowiednią wersją dla mojej wersji szyn

3

Biorąc pod uwagę, że masz rzeczywisty błąd segmentacji, postawiłbym na problem z twoim gemem w połączeniu z libpg. Czy przez jakiś czas aktualizowałeś swój system operacyjny?

Jeśli wydaje się to uzasadnione, możesz spróbować zapisać kopię zapasową bazy danych, nukingować istniejącą instalację pg (bazę danych, biblioteki i klejnoty), a następnie zainstalować ją ponownie w nadziei usunięcia wszystkich niezgodności powodujących problem.

+0

+1 za zauważenie SIG11 i zadawanie właściwych pytań – krichard

1

Mam MySQL i PostgreSQL w tej samej aplikacji. Oto kroki, które podjąłem, aby skonfigurować bazę danych PostgreSQL.

  1. Instalacja PostgreSQL i jego bibliotek sudo apt-get install postgresql postgresql-contrib libpq-dev
  2. Po instalacji utworzyć użytkownika dla PostgreSQL sudo -u postgres createuser --superuser $USER lub sudo -u postgres createuser pgs_root
  3. Ustaw hasło użytkownika dla użytkownika postgresql sudo -u postgres psql postgres (For psql prompt) postgres=# \password <user> dla ex.- postgres=# \passsword pgs_root
  4. Skonfiguruj p Plik ostgresql.conf aby PostgreSQL słuchać localhost lub słuchać na zewnętrznym IP lub coś zmienić tę linię albo do IP lub „localhost” gedit /etc/postgresql/8.4/main/postgresql.conf listen_addresses = 'localhost'
  5. Aby aplikacja łączyła się z bazą danych obecną w PostgreSQL, skonfiguruj ją w bazie danych.yml

    development_postgres: adapter: postgresql database: connect_postgres username: pgs_root password: root123 host: 127.0.0.1

  6. rake db:create RAILS_ENV=development_postgres

jak MySQL Query Browser, istnieje GUI dla PostgreSQL nazywa pgAdmin. Aby zainstalować

sudo apt-get install pgadmin3 
0

aktualizacji wszystkie kamienie poleceniem Bundle Aktualizacja następnie uruchomić bundle exec rake db: migrować, to działa na mnie.

najlepiej szczęście

0

miałem ten sam problem i próbował niemal każde rozwiązanie w internecie bez rezultatów.

Ale w końcu znalazłem rozwiązanie.

Odpowiedzią jest nuke (reinstalować) wszystko. To znaczy:

  • resinstall PostgreSQL i jego biblioteki (postgresql-9.1 postgresql-client postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-contrib postgresql-contrib-9.1 postgresql-server-dev-9.1 libpgsql-ruby libpq-dev etc)

  • usunąć całkowicie i stworzyć gemsets Ruby (ten, który jest na podsłuchu)

  • Reinstall Ruby np. rvm reinstall 1.9.3 (jest to bardzo ważne, bez tego kroku nie będzie działać)

  • Jeśli masz przestarzałe biblioteki (libpgsql-ruby1.8 itp.), Usuń je.

PS Ten problem pojawił się na moim komputerze po aktualizacji Debiana (z Squeeze na Wheezy).

Edit:

Więcej wyjaśnieniem tego błędu:

https://bitbucket.org/ged/ruby-pg/issue/76/segfault-on-ruby-18-and-ruby-19-using#comment-590323

0

czasami jest to spowodowane przez zderzenia między wieloma wersjami libssl

spróbować:

  • apt-ge t usunąć libssl0.9.8
  • RVM reinstall domyślny
Powiązane problemy