0
0

More than 1 year has passed since last update.

<備忘録>RailsアプリをHerokuデプロイでエラー

Last updated at Posted at 2021-12-10

RailsアプリをHerokuデプロイ時に2つのエラーが発生しました。
今回はそのうちの1つをメモとして残します。

環境

  • macOS Monterey 12.0.1
  • Ruby 3.0.3
  • Bundler 2.2.32
  • Rails 6.1.4.1

heroku push でエラー発生

$git push heroku main
で、以下のエラーが発生しデプロイに失敗。

エラーメッセージ
remote: ###### WARNING:
remote: 
remote:        You have not declared a Ruby version in your Gemfile.
remote:        
remote:        To declare a Ruby version add this line to your Gemfile:
remote:        
remote:        ```
remote:        ruby "2.7.4"
remote:        ```
remote:        
remote:        For more information see:
remote:          https://devcenter.heroku.com/articles/ruby-versions

エラーメッセージによると、
『Rubyのバージョンを宣言していません。Gemfileに追加してね』
とのこと。

どうやら、GemfileにRubyのバージョンを記載しないといけないみたいです。

記載してみましょう。

GemfileにRubyのバージョンを宣言

Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
#Rubyの任意のバージョンを記載
ruby '3.0.3' 

Gemfileを更新したのでbundle installを実行します。

$ bundle install

無事更新できました。

Herokuへデプロイ

Herokuへデプロイします。

$ git add -A
$ git commit -m "add Ruby version in Gemfile"
$ git push heroku main

以上、Herokuデプロイ時エラー発生の対応でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0