Matt
Matt

Reputation: 6330

Automatically using the latest patch version of Ruby on Heroku

I recently updated my application to Rails 6, and would like Heroku to automatically use the latest patch version of Ruby (i.e. 2.6.x) when I deploy. According to the Heroku documentation, I should be able to do this by specifying ruby '~> 2.6.0 in my Gemfile, but I still receive this message on deploy:

enter image description here

Here are the top lines of my Gemfile:

# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '~> 2.6.4'

With everything I've tried Heroku still locks me to ruby-2.6.4 ("Using Ruby version: ruby-2.6.4") and throws the warning above. I've tried:

Any help would be appreciated!

Upvotes: 1

Views: 111

Answers (2)

max
max

Reputation: 102250

Don't use pragmatic versioning for Ruby.

Having Ruby automatically upgrade to the latest minor version seems like a good idea when viewed naively but in real life it should make you very nervous. Software is imperfect and even software that closely follows semantical versioning could potentially break your application as software is written by humans.

You want to test, develop and deploy on the exact same version of Ruby down to the patch-level. Use a fixed version constraint.

Upvotes: 1

Tin Nguyen
Tin Nguyen

Reputation: 5330

You already linked this document: https://devcenter.heroku.com/articles/ruby-versions#ruby-version-specifiers

If you want to install exactly ruby 2.6.5 you need to write:

ruby "2.6.5"

I recently updated my application to Rails 6, and would like Heroku to automatically use the latest patch version of Ruby (i.e. 2.6.x) when I deploy. According to the Heroku documentation, I should be able to do this by specifying ruby '~> 2.6.0 in my Gemfile, but I still receive this message on deploy

That's a misunderstanding. It does not say it will use the latest version of Ruby 2.6.x.

You can put this there:

ruby '~> 2.6.5'

This will install ruby version 2.6.5 or higher. This is something that you have to manually increase. But generally if it works for a lesser version you should still allow them.

Upvotes: 1

Related Questions