When you select the option to Set up container image automatically, if you do not specify a version in your application’s code, the buildpack will use the latest available version. If you want to use a different language version for your application, you’ll need to set the version in your application’s files.

The method for setting the version varies by language. Below we’ve included examples for currently supported languages.

Go

To specify your Go version, include the following in your application’s go.mod file:

// +heroku goVersion go1.11
go 1.11

Java

To specify your Java version, include the following in your application’s system.properties file:

java.runtime.version=11

Node.js

To specify your Node.js and npm versions, include the following in your application’s package.json file:

"engines": {
  "node": "^16.14.0",
  "npm": "^8.3.1"
}

Python

To specify your Python version, include the following in your application’s runtime.txt file:

python-3.10.6

You can also specify module versions within the requirements.txt file:

Django==3.2
virtualenv==20.18.0

React

To specify your React, Node.js, and npm versions, include the following in your application’s package.json file:

"react": "^17.0.2"
"engines": {
"node": "12.18.3"
"npm": "6.14.6"
}

Ruby

To specify your Ruby version, include the following in your Gemfile:

"https://rubygems.org"
ruby "2.5.1"

Scala

To specify your Scala version, include the following in your application’s build.sbt file:

scalaVersion := "2.13.8"

PHP

To specify your PHP version, include the following in your application’s composer.json file:

{
  "require": {
    "php": "~8.0.0"
  }
}