A Heroku buildpack for deploying Ruby applications using TruffleRuby, a high-performance Ruby implementation built on GraalVM.
- TruffleRuby 24.1.1 (compatible with GraalVM for JDK 21 LTS)
- Automatic Bundler installation and dependency resolution
- rbenv integration for Ruby version management
- Support for Rack and Rails applications
- Automatic Procfile generation
- PostgreSQL addon detection
heroku buildpacks:set https://github.com/henryaj/truffleruby-buildpackOr add it to your app.json:
{
"buildpacks": [
{ "url": "https://github.com/henryaj/truffleruby-buildpack" }
]
}- Heroku stack: heroku-22 or heroku-24
Gemfilein repository rootGemfile.lockfor dependency installation
Configure the buildpack using environment variables:
| Variable | Default | Description |
|---|---|---|
TRUFFLERUBY_VERSION |
24.1.1 |
TruffleRuby version to install |
TRUFFLERUBY_VARIANT |
community-jvm |
Distribution variant (community or community-jvm) |
TRUFFLERUBY_ARCH |
linux-amd64 |
Target architecture |
community-jvm(default): Runs on the JVM. Better compatibility across Linux distributions. Slower cold start but better peak performance after warmup. Includes GraalVM JDK.community: Native standalone image. Faster cold start but may have glibc compatibility issues on some systems (e.g., Heroku-24).
# Use a specific TruffleRuby version
heroku config:set TRUFFLERUBY_VERSION=24.0.0
# Use native variant (faster startup, but may have compatibility issues)
heroku config:set TRUFFLERUBY_VARIANT=community| TruffleRuby Version | GraalVM JDK | Ruby Compatibility |
|---|---|---|
| 24.1.x | JDK 21 LTS | Ruby 3.2 |
| 24.0.x | JDK 21 LTS | Ruby 3.2 |
| 23.1.x | JDK 21 LTS | Ruby 3.2 |
The buildpack follows Heroku's standard three-phase buildpack interface:
Checks for a Gemfile in the application root. If found, the buildpack is activated.
- Installs required APT packages (openssl, make, clang, llvm, libssl-dev, git)
- Downloads and installs TruffleRuby standalone distribution
- Runs TruffleRuby's post-install hook (compiles OpenSSL bindings)
- Installs rbenv for Ruby version management
- Links TruffleRuby as an rbenv-managed version
- Installs Bundler and runs
bundle install
Generates default process types based on detected application type:
- Rails apps:
rails serverfor web,rails consolefor console - Rack apps:
rackupfor web - Generic Ruby:
rakeandirbconsole
Also suggests the heroku-postgresql addon if the pg gem is detected.
This buildpack uses BATS (Bash Automated Testing System) for testing.
# Install BATS (macOS)
brew install bats-core
# Install BATS (Ubuntu/Debian)
sudo apt-get install bats
# Run all tests
bats test/
# Run specific test file
bats test/detect.batsShell scripts are linted with ShellCheck:
# Install ShellCheck (macOS)
brew install shellcheck
# Run linting
shellcheck bin/* lib/*.sh .profile.d/*truffleruby-buildpack/
├── bin/
│ ├── compile # Main build script
│ ├── detect # Buildpack detection
│ ├── install_binaries # APT package installation
│ └── release # Release configuration
├── lib/
│ └── common.sh # Shared functions and configuration
├── .profile.d/
│ └── graal_env # Runtime environment setup
├── test/
│ ├── test_helper.bash # BATS test utilities
│ ├── detect.bats # Detection tests
│ ├── common.bats # Library function tests
│ ├── release.bats # Release script tests
│ └── fixtures/ # Test fixtures
└── .github/
└── workflows/
└── ci.yml # GitHub Actions CI
Check that the TruffleRuby version exists. View available releases at: https://github.com/oracle/truffleruby/releases
If you see errors like cannot execute: required file not found at runtime, this usually indicates glibc compatibility issues with the native variant. Switch to the JVM variant:
heroku config:set TRUFFLERUBY_VARIANT=community-jvm
git commit --allow-empty -m "Trigger rebuild"
git push heroku mainThe buildpack automatically runs TruffleRuby's post-install hook to compile OpenSSL bindings. If you encounter SSL errors, ensure libssl-dev is available (it's included by default).
TruffleRuby may require more memory than MRI Ruby. Consider:
- Using a larger dyno size
- Using the
communityvariant (native image, lower memory) if compatible with your system - Tuning JVM memory with
JAVA_OPTSfor thecommunity-jvmvariant
MIT
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
bats test/ - Run linting:
shellcheck bin/* lib/*.sh - Submit a pull request