@chickentatuta

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

RailsアプリのHerokuへのデプロイについて

初めまして。
Rails独学初学者の者です。

Herokuへとデプロイしたところ、Apprication Errorが出てしまいました。

ページの案内の通り

heroku logs --tail

を実行したところ、以下の文が出てきました。

at=error code=H10 desc="App crashed" method=GET path="/"

他の方の記事に倣い、以下を実行しました。

heroku run rails c

その結果、怪しいなと思う箇所は以下の3文です。

/app/vendor/ruby-3.3.5/lib/ruby/3.3.0/bundler/rubygems_integration.rb:237:in `block (2 levels) in replace_gem': can't activate pg (~> 1.1), already activated pg-0.20.0. Make sure all dependencies are added to Gemfile. (Gem::LoadError)
/app/vendor/ruby-3.3.5/lib/ruby/3.3.0/json/generic_object.rb:2: warning: /app/vendor/ruby-3.3.5/lib/ruby/3.3.0/ostruct.rb was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add ostruct to your Gemfile or gemspec to silence this warning.
/app/vendor/ruby-3.3.5/lib/ruby/3.3.0/bundler/rubygems_integration.rb:237:in `block (2 levels) in replace_gem': Error loading the 'postgresql' Active Record adapter. Missing a gem it depends on? can't activate pg (~> 1.1), already activated pg-0.20.0. Make sure all dependencies are added to Gemfile. (LoadError)

GemfileにはProductionとしてPostgreSQLの記述をしてあります。
Errorにある1.1のバージョンになるように指定もしております。

source "https://rubygems.org"
ruby "3.3.5"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.2.1", ">= 7.2.1.2"
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
# Use sqlite3 as the database for Active Record
# gem "sqlite3", ">= 1.4"
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
# Use Redis adapter to run Action Cable in production
# gem "redis", ">= 4.0.1"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"

  gem "sqlite3"

  # Static analysis for security vulnerabilities [https://brakemanscanner.org/]
  gem "brakeman", require: false

  # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
  gem "rubocop-rails-omakase", require: false
end

group :development do
  # Use console on exceptions pages [https://github.com/rails/web-console]
  gem "web-console"
end

group :test do
  # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
  gem "capybara"
  gem "selenium-webdriver"
end

gem "dotenv-rails"
gem "geocoder"
gem "gon"

group :production do
  gem "pg", "1.1"
end

解決方法をご存知の方がいらっしゃいましたら、ご教授いただけますと幸いです。
拙い文を最後までありがとうございました。
なにとぞ、よろしくお願いいたします。

0 likes

1Answer

Your answer might help someone💌