Heroku-22 Stack
Last updated October 23, 2024
Table of Contents
This article describes the Heroku-22 stack, based on Ubuntu 22.04. What is a stack?
What’s new
This stack is now based on Ubuntu 22.04, compared to Ubuntu 20.04 used in the Heroku-20 stack.
The most important changes compared to Heroku-20 are:
- The stack no longer includes a system Ruby installation. This will not affect the vast majority of users, since Ruby apps will use the Ruby installation provided by the Ruby buildpack.
- The stack no longer includes a system Python 2 installation (accessed on Heroku-20 via the
python2
command). Python 3 continues to be available via thepython
andpython3
commands, as it was for Heroku-20.
Available software
Every stack on Heroku supports different operating system packages and language runtime versions. This support is typically confined to software that was still actively developed by the respective maintainers at the time the stack was first released.
Language runtimes
For the most accurate information on supported language runtime versions, please check the individual language pages:
Buildpack | Shorthand | Runtime versions |
---|---|---|
Ruby | heroku/ruby |
Runtime versions |
Node.js | heroku/nodejs |
Runtime versions |
Python | heroku/python |
Runtime versions |
Java | heroku/java |
Runtime versions |
PHP | heroku/php |
Runtime versions |
Go | heroku/go |
Runtime versions |
Operating system packages
For a full list of operating system packages available on Heroku-22, please refer to article Ubuntu Packages on Heroku Stacks.
Support period
Heroku-22 is based on Ubuntu 22.04. It will be supported through April 2027. Learn more about Heroku’s stack update policy.
Using Heroku-22
Heroku-24 is currently the default stack for newly created apps.
You can specify a stack when creating an app:
$ heroku create --stack heroku-22
You may change the stack on an existing app; the next build performed will then use the new stack:
$ heroku stack:set heroku-22
If you are using app.json
, you should also specify the stack there to ensure that your Review Apps and Heroku CI runs use the same stack:
{
"stack": "heroku-22"
}
An existing app’s stack cannot be changed using app.json
. The stack specified is only applied to newly created apps that are a Review App, a Heroku CI test run app, or an app created using a Heroku Button.
Upgrading to Heroku-22
Please refer to the stack upgrading guide to understand the procedures to follow when upgrading to a new stack.
We recommend that you monitor your application closely after migrating an app to the new stack to ensure it’s performing correctly.
Upgrade notes
System Ruby is no longer installed
The stack no longer includes a system Ruby installation. This will not affect the vast majority of users, since by default Ruby apps will use the Ruby installation provided by the Ruby buildpack instead.
If your app is implemented in a language other than Ruby, but relies on Ruby for scripting purposes e.g. during startup or for controlling workers, you may have to add the heroku/ruby
buildpack to your app.
If your application uses Ruby and you see ruby: command not found
errors, check that you haven’t accidentally been using the system-level Ruby installation; you may do so by verifying the Ruby buildpack is present in your application’s list of buildpacks using heroku buildpacks
. If the heroku/ruby
buildpack (or a GitHub URL equivalent) is missing, see our buildpacks documentation for how to add it. You will need to check the buildpack order carefully - the newly added Ruby buildpack may need to go prior to any other buildpacks, depending on exactly where Ruby is being used.
If after adding the Ruby buildpack, you are still seeing ruby: command not found
errors from profile.d/
scripts at application boot, this is due to the fact that profile.d/
scripts are sourced in alphabetical order, and buildpack Ruby is only added to PATH
once the profile.d/ruby.sh
script runs. Any other profile.d/
scripts will need to have a name that sorts alphabetically after ruby.sh
. Alternatively, you can move the contents of any affected profile.d/
scripts to the .profile file instead, which is guaranteed to always run after all other profile.d/*
scripts.
If you are a maintainer of a buildpack that uses Ruby, you will need to either:
- Modify the buildpack so that it vendors Ruby as part of the build (example).
- Rewrite the Ruby parts of the buildpack to be shell scripts instead.
- Update the buildpack documentation to say end users should add the Ruby buildpack prior to the buildpack in question (they will also need to ensure minimal
Gemfile
/Gemfile.lock
files exist, so that the Ruby buildpack passes detection).
System Python 2 is no longer installed
The stack no longer includes a system Python 2 installation (accessed on Heroku-20 via the python2
command), since Python 2 has been sunset upstream for some time.
The system Python installation is not the same as the one provided by the Python buildpack (which had previously dropped support for Python 2, starting in Heroku-20).
Python 3 continues to be available via the python
and python3
commands (either via system Python, or the buildpack provided Python installation), as it was for Heroku-20.
OpenSSL 3
Ubuntu 22.04 ships with OpenSSL 3.0. OpenSSL 1.1 is not available as a runtime library.
If you see OpenSSL/libssl related errors (for example libssl.so.1.1: cannot open shared object file
or SSL_read: unexpected eof while reading
, but there will be many other variations), you will need to update your dependencies and/or third-party buildpacks to versions that are compatible with OpenSSL 3, and ensure that dependencies or binaries you use are compiled against OpenSSL 3.
In addition, OpenSSL 3 drops default support for a number of legacy/insecure cryptographic algorithms. If you see TLS/SSL related failures connecting from your application to external services, it is likely that those servers are running outdated/insecure software or configurations, that will need to be fixed by the maintainers of those services.
The static buildpack is no longer supported
The experimental heroku-buildpack-static buildpack is not supported on Heroku-22. If your application is using that buildpack (check the output of the heroku buildpacks
command for either heroku-community/static
or heroku-buildpack-static
), you will need to switch to the more modern and regularly maintained Nginx buildpack instead (available via heroku-community/nginx
).
For more information, see this migration guide.
Heroku-22 Docker image
Heroku-22 is available as two Docker images:
- The runtime image (
heroku/heroku:22
), which is recommended over the build image for most workloads. - The build image (
heroku/heroku:22-build
), which is larger as it includes development headers and toolchains. It is only recommended for customers that need to compile source code or dependencies.
Use the following command in your Dockerfile
to use Heroku-22 as your base image:
FROM heroku/heroku:22
To learn more about deploying Docker images, please refer to the Heroku Container Registry and Runtime documentation.