LoginSignup
6
4

More than 5 years have passed since last update.

HerokuにデプロイでRubyバージョンサポート外エラー

Last updated at Posted at 2018-12-23

はじめに

HerokuのStackをバージョンアップしようとして、エラーになったので、
作業記録としても、対応作業しながら投稿。

経緯

Stackを最新バージョンのHeorku-18に更新し、デプロイしようとしたところ、次のエラーが発生。

エラー
 !     This version of Ruby is not available on Heroku-18. The minimum supported version
 !     of Ruby on the Heroku-18 stack can found at:
 !     
 !     https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

原因は、Rubyが2.4.1だったからの模様。
↑のURLを見るとわかるが、サポートは2.4.5

対応手順

1. Rubyバージョンアップ

1-1. Ruby2.4.5インストール

私の環境では、rbenvでRubyを管理しているため、rbenvでRubyのバージョンアップを試みる。

バージョンアップ(2.4.5インストール)
$ rbenv install 2.4.5
ruby-build: definition not found: 2.4.5

See all available versions with `rbenv install --list'.

If the version you need is missing, try upgrading ruby-build:

  brew update && brew upgrade ruby-build

無いと言われる?!

調べたところ、rbenvのバージョンが古いらしい。
参考:https://qiita.com/_kanacan_/items/c1499f6c13b1c41da982

1-2. rbenvのバージョンアップ

rbenvのバージョンアップ
$ brew upgrade rbenv ruby-build
確認
$ rbenv install -l
  中略
  2.4.1
  2.4.2
  2.4.3
  2.4.4
  2.4.5
  2.5.0-dev
  2.5.0-preview1
  2.5.0-rc1
  2.5.0
  2.5.1
  2.5.2
  2.5.3

あった!!!

というわけで、再度インストール

バージョンアップ(2.4.5インストール)
$ rbenv install 2.4.5
ruby-build: use openssl from homebrew
Downloading ruby-2.4.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.5.tar.bz2
Installing ruby-2.4.5...
ruby-build: use readline from homebrew
Installed ruby-2.4.5 to /Users/{user_name}/.rbenv/versions/2.4.5

2. プロジェクトに適用

Rubyがインストールできたので、各プロジェクトに適用していきます。

プロジェクトのディレクトリに移動後、

2-1. rbenvの設定変更

プロジェクトに適用
$ rbenv local 2.4.5
確認
$ rbenv versions
  system
  2.4.1
* 2.4.5 (set by /{project_dir}/.ruby-version)

2-2. Railsプロジェクトに適用

bundle_install
$ bundle install
rbenv: bundle: command not found

The `bundle' command exists in these Ruby versions:
  2.4.1

Rubyごとにbundleを入れ直さないと行けない模様。

bundle入れ直し
$ gem install bundler
Fetching: bundler-1.17.2.gem (100%)

Successfully installed bundler-1.17.2
Parsing documentation for bundler-1.17.2
Installing ri documentation for bundler-1.17.2
Done installing documentation for bundler after 12 seconds
1 gem installed
再度bundleinstall
$ bundle install
Your Ruby version is 2.4.5, but your Gemfile specified 2.4.1

Gemfileを変えなきゃいけなかったので、変更後再度!

Gemfile変更後再度!
$ bundle install

完了!!!

6
4
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
6
4