2013-10-09 73 views
0

相當新的heroku,所以請原諒我的noobness。Heroku上的Rails應用程序無法識別pg Gem

試圖部署一個能在我的本地機器上正常工作的應用程序,以heroku。

它可以部署罰款後

git push heroku master 

但我得到以下錯誤,當我看Heroku的日誌:

2013-10-09T02:56:42.363522+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/server.rb:48:in `app' 
2013-10-09T02:56:42.363141+00:00 app[web.1]: from /app/config.ru:in `<main>' 
2013-10-09T02:56:42.363522+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>' 
2013-10-09T02:56:42.363522+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app' 
2013-10-09T02:56:42.406543+00:00 app[web.1]: => Ctrl-C to shutdown server 
2013-10-09T02:56:42.406543+00:00 app[web.1]: => Rails 4.0.0 application starting in production on http://0.0.0.0:44409 
2013-10-09T02:56:42.363522+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap' 
2013-10-09T02:56:42.406543+00:00 app[web.1]: => Booting WEBrick 
2013-10-09T02:56:42.406543+00:00 app[web.1]: Exiting 
2013-10-09T02:56:43.780131+00:00 heroku[web.1]: State changed from starting to crashed 
2013-10-09T02:56:43.770751+00:00 heroku[web.1]: Process exited with status 1 
2013-10-09T02:59:44.437016+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=career-agent.herokuapp.com fwd="74.9.178.228" dyno= connect= service= status=503 bytes= 
2013-10-09T02:59:44.746548+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=career-agent.herokuapp.com fwd="74.9.178.228" dyno= connect= service= status=503 bytes= 
2013-10-09T03:04:32.057876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=career-agent.herokuapp.com fwd="74.9.178.228" dyno= connect= service= status=503 bytes= 
2013-10-09T03:04:31.565122+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=career-agent.herokuapp.com fwd="74.9.178.228" dyno= connect= service= status=503 bytes= 
2013-10-09T03:06:56.946173+00:00 heroku[web.1]: State changed from crashed to starting 
2013-10-09T03:07:02.040757+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 10939 -e $RAILS_ENV` 
2013-10-09T03:07:09.880708+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/connection_specification.rb:55:in `resolve_hash_connection' 
2013-10-09T03:07:09.880708+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval' 
2013-10-09T03:07:09.880708+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection' 
2013-10-09T03:07:09.880708+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/connection_specification.rb:58:in `rescue in resolve_hash_connection': Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile. (Gem::LoadError) 

我加gem pg我的Gemfile:

source 'https://rubygems.org' 

gem 'protected_attributes' 

group :production do 
    # gems specifically for Heroku go here 
    gem "pg" 
end 

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '4.0.0' 

# Use mysql as the database for Active Record 
gem 'mysql2' 

# Use SCSS for stylesheets 
gem 'sass-rails', '~> 4.0.0' 

# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 

# Use CoffeeScript for .js.coffee assets and views 
gem 'coffee-rails', '~> 4.0.0' 

# See https://github.com/sstephenson/execjs#readme for more supported runtimes 
# gem 'therubyracer', platforms: :ruby 

# Use jquery as the JavaScript library 
gem 'jquery-rails' 

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 
gem 'turbolinks' 

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 1.2' 

group :doc do 
    # bundle exec rake doc:rails generates the API under doc/api. 
    gem 'sdoc', require: false 
end 

# Use ActiveModel has_secure_password 
# gem 'bcrypt-ruby', '~> 3.0.0' 

# Use unicorn as the app server 
# gem 'unicorn' 

# Use Capistrano for deployment 
# gem 'capistrano', group: :development 

# Use debugger 
# gem 'debugger', group: [:development, :test] 

當我做bundle show pg

/Users/Calvino/.rvm/gems/ruby-1.9.3-p448/gems/pg-0.16.0 

我已經運行bundle install

Calvins-Air:LifeAgent Calvino$ bundle install 
Using rake (10.1.0) 
Using i18n (0.6.5) 
Using minitest (4.7.5) 
Using multi_json (1.7.9) 
Using atomic (1.1.13) 
Using thread_safe (0.1.2) 
Using tzinfo (0.3.37) 
Using activesupport (4.0.0) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.0) 
Using mime-types (1.25) 
Using polyglot (0.3.3) 
Using treetop (1.4.15) 
Using mail (2.5.4) 
Using actionmailer (4.0.0) 
Using activemodel (4.0.0) 
Using activerecord-deprecated_finders (1.0.3) 
Using arel (4.0.0) 
Using activerecord (4.0.0) 
Using coffee-script-source (1.6.3) 
Using execjs (2.0.1) 
Using coffee-script (2.2.0) 
Using thor (0.18.1) 
Using railties (4.0.0) 
Using coffee-rails (4.0.0) 
Using hike (1.2.3) 
Using jbuilder (1.5.1) 
Using jquery-rails (3.0.4) 
Using json (1.8.0) 
Using mysql2 (0.3.13) 
Using pg (0.16.0) 
Using protected_attributes (1.0.3) 
Using bundler (1.3.5) 
Using tilt (1.4.1) 
Using sprockets (2.10.0) 
Using sprockets-rails (2.0.0) 
Using rails (4.0.0) 
Using rdoc (3.12.2) 
Using sass (3.2.10) 
Using sass-rails (4.0.0) 
Using sdoc (0.3.20) 
Using turbolinks (1.3.0) 
Using uglifier (2.2.1) 
Your bundle is complete! 
Use `bundle show [gemname]` to see where a bundled gem is installed. 

我一直在谷歌上搜索了幾個小時也沒有用。任何幫助?顯然pg是在我的系統上找到的,爲什麼在Heroku上找不到它?

+0

你解決了問題還是仍然有問題? –

+0

感謝gabrielhilal我想我解決了我原來的問題。但是我現在得到一個新的錯誤。編輯我的原始帖子。 – CHawk

+0

編輯是無關緊要的,請刪除編輯的部分,因爲它不是錯誤,你只是忘了運行你的遷移到創建表。 –

回答

2

你可能沒有推到本地的Heroku加入pg寶石後....嘗試以下操作:

git add -A 
git commit -m 'pg gem added' 
git push 
git push heroku 

我希望它可以幫助...

+0

奇怪的是,我使用github GUI,我知道我已經提交併同步,但這似乎解決了我原來的問題。但現在我得到一個新的錯誤,將編輯我原來的帖子。 – CHawk

0

我也看到mysql2包括寶石在你的Gemfile。不知道這是否與pg衝突。嘗試限制mysql2 gem僅適用於非生產環境。

相關問題