Ruby Application Behavior on Heroku
Last updated December 03, 2024
Table of Contents
Heroku fully supports pure Ruby applications, such as headless processes and evented web frameworks like Goliath. This article describes their behavior.
Auto-Detection
When Heroku recognizes a deployed app as a pure Ruby application, we respond with -----> Ruby app detected
at deploy time.
$ git push heroku main
-----> Ruby app detected
Config Vars
We set the following environment variables on Ruby apps, depending on if you use Cloud Native Buildpacks or not:
Classic Ruby Buildpack Config Vars
GEM_PATH
=>vendor/bundle/#{RUBY_ENGINE}/#{RUBY_ABI_VERSION}
LANG
=>en-us
PATH
=>bin:vendor/bundle/#{RUBY_ENGINE}/#{RUBY_ABI_VERSION}/bin:/usr/local/bin:/usr/bin:/bin
DISABLE_SPRING
=>1
GEM_PATH
is set to the Bundler gem vendor directory.
Ruby Cloud Native Buildpack Config Vars
We set defaults for the following environment variables:
JRUBY_OPTS="-Xcompile.invokedynamic=false"
- Invoke dynamic is a feature of the JVM intended to enhance support for dynamically typed languages, such as Ruby. This setting caused issues with Physion Passenger 4.0.16 and was disabled details. You can override this value.RACK_ENV=${RACK_ENV:-"production"}
- An environment variable that can affect Rack-based web servers and web apps behavior. You can override this value.RAILS_ENV=${RAILS_ENV:-"production"}
- A value used by all Rails apps. By default, Rails ships with three environments:development
,test,
andproduction
. We recommend that all apps being deployed useproduction
and against using a custom env such asstaging
details. You can override this value.SECRET_KEY_BASE=${SECRET_KEY_BASE:-<generate a secret key>}
- In Rails, 4.1+ apps, a value for generating cryptographic tokens for various things. Notably, this value is used in generating user sessions, so modifying it between builds has the effect of logging out all users. This buildpack provides a default generated value. You can override this value.BUNDLE_WITHOUT=development:test
- Tells Bundler not to installdevelopment
ortest
groups duringbundle install
. You can override this value.
Environment variables modified - In addition to the default list, the buildpack modifies these environment variables:
BUNDLE_BIN=<bundle-path-dir>/bin
- Install executables for all gems into the specified path.BUNDLE_CLEAN=1
- After a successful bundle install, the Bundler automatically runsbundle clean
to remove all stale gems from previous builds that are no longer specified in theGemfile.lock
.BUNDLE_DEPLOYMENT=1
- RequiresGemfile.lock
to be in sync with the currentGemfile
.BUNDLE_GEMFILE=<app-dir>/Gemfile
- Tells Bundler where to find theGemfile
.BUNDLE_PATH=<bundle-path-dir>
- Directs Bundler to install gems to this pathDISABLE_SPRING= "1"
- Spring is a library that tries to cache application state by forking and manipulating processes with the goal of decreasing development boot time. Disabling it in production removes significant problems. See details.GEM_PATH=<bundle-path-dir>
- Tells Ruby where gems are.MALLOC_ARENA_MAX=2
- Controlsglibc
memory allocation behavior with the goal of decreasing overall memory allocated by Ruby. See details.PATH
- Various executables are installed and thePATH
env var will be modified so they can be executed at the system level. This is mostly done via interfaces provided bylibcnb
and CNB layers rather than directly.RAILS_LOG_TO_STDOUT=" enabled"
- Sets the default logging target toSTDOUT
for Rails 5+ apps. detailsRAILS_SERVE_STATIC_FILES=" enabled"
- Enables theActionDispatch::Static
middleware for Rails 5+ apps so that the Ruby webserver, such as Puma, serves static files such as the ones inpublic/assets
. See details.
Add-ons
If you created your account before May 15, 2023 or if you asked Heroku Support to enable Heroku Postgres auto-provisioning for your account, see Ruby Database Auto-Provisioning.
Process Types
No default web
process type is created if a pure Ruby application is detected.