簡體   English   中英

哈特爾(Hartl)在推向heroku的第7章中,“ pg不是捆綁包的一部分”,但它確實是

[英]Hartl's Chapter 7 when pushing to heroku, “pg is not part of the bundle” but it is

因此,我正在閱讀Hartl的RoR教程,並且在第7章結尾 我正在嘗試部署到heroku。 一切直到

heroku run rake db:migrate

步驟有效,但該步驟給了我下面的錯誤。 我已經運行了幾次bundle install ,但我不確定問題出在哪里。 另外,即使我運行heroku create --stack cedar然后git push heroku ,我也無法在線訪問heroku應用程序。 當我進入heroku應用程序URL時,它只是給我一個應用程序錯誤。

我目前正在運行Postgres.app,但我的rails服務器尚未部署。

包括我的Gemfiledatabase.yml 隨時查看http://github.com/sambaek上的代碼

有人可以幫忙嗎? 謝謝!

終端輸出

heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.1
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
Connecting to database specified by DATABASE_URL
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)

寶石文件

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.0.4'
gem 'bcrypt-ruby', '3.0.1'

group :development, :test do
  gem 'rspec-rails', '2.11.0'
  gem 'guard-rspec', '0.5.5'
  gem 'pg'
  # gem 'sqlite3'
  gem 'guard-spork', '0.3.2'
  gem 'spork', '0.9.0'
  gem 'factory_girl_rails', '1.4.0'
end

gem 'annotate', '2.5.0', group: :development

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.5'
  gem 'coffee-rails', '3.2.2'
  gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.2'

group :test do
  gem 'capybara', '1.1.2'
  gem 'rb-fsevent', '0.9.1', :require => false
  gem 'growl', '1.0.3'
end

config / database.yml

# postgresql
development:
  host: localhost
  adapter: postgresql
  encoding: utf8
  database: sample_app_development
  pool: 5
  username: 
  password: 

test:
  host: localhost
  adapter: postgresql
  encoding: utf8
  database: sample_app_test
  pool: 5
  username: 
  password: 

production:
  adapter: postgresql
  encoding: utf8
  database: sample_app_production
  pool: 5
  username:
  password:


# sqlite3
# development:
#   adapter: sqlite3
#   database: db/development.sqlite3
#   pool: 5
#   timeout: 5000

# # Warning: The database defined as "test" will be erased and
# # re-generated from your development database when you run "rake".
# # Do not set this db to the same as development or production.
# test:
#   adapter: sqlite3
#   database: db/test.sqlite3
#   pool: 5
#   timeout: 5000

# production:
#   adapter: sqlite3
#   database: db/production.sqlite3
#   pool: 5
#   timeout: 5000

兩個問題:

  1. 您在github上的代碼顯示pg gem在production組中-只需將其從該組中刪除,以便將其包含在所有環境中。
  2. 對問題的更新(其中顯示了Gemfileconfig/database.yml )將pg gem放置在testdevelopment環境中,Heroku不會在其中安裝它

我在下面看到您的答案,但是,如果您在所有環境中都使用pg ge,則無需將pg gem放在任何組中(看起來像是基於config/database.yml文件)。

原來,當我運行heroku run rake db:migrate時,沒有安裝pg gem,因為我的Gemfile沒有單獨的production組。 現在可以使用了。 感謝您抽出寶貴時間嘗試解決問題的任何人!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM