The Ruby runtime Stay organized with collections Save and categorize content based on your preferences.
Note: SomeRuby runtimes have reachedend of support. You cannot re-deployversions that use runtimes after their end of support date. We recommend thatyouupgrade your appto use the latest version of Ruby.
The Ruby runtime is the software stack responsible forinstalling your application code and dependencies, and then running thatapplication in the flexible environment.
Ruby versions
Ruby 3.4 usesbuildpacks. For the full list of supportedRuby versions, and their corresponding Ubuntuversion, see theRuntime support schedule.
To use a supported Ruby version, you must:
Specify a Ruby version in your
Gemfile.RUBYVERSIONruby"3.4.x"Install gcloud CLI version420.0.0 or later. You can updateyour CLI tooling by running the
gcloud components updatecommand. To view your installed version, you can run thegcloud versioncommand.Specify the
operating_systemsetting in yourapp.yamlfile:runtime:rubyenv:flexruntime_config:operating_system:"ubuntu22"Optionally, you can specify a version of the Ruby interpreterusing a
.ruby-versionfile in your application directory. For example,3.4.x
Previous versions
Warning: Rubyversion 3.1 and earlier have reached end ofsupport. App Engine blocks you from deploying your applications using runtimesthat have reached end of support. We recommend that you migrate your app to use asupported version of Rubyor use acustom runtime.To use Ruby runtimeversion 3.1 and earlier, specify a version of the Rubyinterpreter using a.ruby-version file in your application directory.
When this file is present, the runtime installs the requested version ofRuby when you deploy your application usingrbenv.If the requested version cannot be installed, App Engine shows an errormessage during deployment.
If you don't provide a.ruby-version file, the Ruby runtime defaults toversion 2.7. Note that the default can change at any time, soit is recommended that your app specifies a Ruby version.
Support for other Ruby runtimes
If you need to use a Ruby version that isn'tsupported, you can create acustom runtime and select avalid base image with the Ruby version you need.
For Google-supplied base images orDocker Ruby base images,seeBuilding custom runtimes.
Dependencies
The runtime looks for aGemfile file in your application's source directory and usesBundler to installany dependencies before starting your application. For more information ondeclaring and managing packages, seeUsing Ruby Libraries.
Using C libraries with Ruby
For Ruby libraries that require C extensions, the headers forthe current Ruby version and the followingUbuntu packages are pre-installed on the system.
autoconfbuild-essentialca-certificatescmakecurlfilegitimagemagicklibcurl3libcurl3-gnutlslibcurl4-openssl-devlibffi-devlibgdbm-devlibgit2-devlibgmp-devlibicu-devlibjemalloc-devlibjemalloc1libmagickwand-devlibmysqlclient-devlibncurses5-devlibpq-devlibqdbm-devlibreadline6-devlibsqlite3-devlibssl-devlibxml2-devlibxslt-devlibyaml-devlibz-devsystemtaptzdata
These packages allow the installation of most popular Ruby libraries. If your applicationrequires additional operating-system level dependencies, you will need to use acustom runtime based on this runtimeto install the appropriate packages.
Application startup
The runtime starts your application using theentrypoint defined inapp.yaml. The entrypoint should start a process thatresponds to HTTP requests on the port defined by the environment variablePORT.For example:
entrypoint:bundleexecrailsserver-p$PORTMost web applications use aRack-supported web serversuch asPuma,Unicorn orThin.
You must add the server as a dependency in your application'sGemfileconfiguration file. The runtime will install all dependencies before yourentrypoint is called.
source"https://rubygems.org"gem"rack"gem"puma"An example entrypoint using puma for a Rails application:
entrypoint:bundleexecrailsserverPuma-p$PORTAn example entrypoint using puma for any Rack application:
entrypoint:bundleexecrackup-sPuma-p$PORTFor applications that can handle requests without a Rack server, you can just execute a ruby script:
entrypoint:bundleexecrubyapp.rbexec function.Shell variables such as$PORT will be replaced normally, but shell syntax suchasif,for andwhile embedded in theentrypoint command will notfunction.Environment variables
The following environment variables are set by the runtime environment:
| Environment Variable | Description |
|---|---|
GAE_INSTANCE | The name of the current instance. |
GAE_MEMORY_MB | The amount of memory available to the application process. |
GAE_SERVICE | The service name specified in your application'sapp.yaml file, or if no service name is specified, it is set todefault. |
GAE_VERSION | The version label of the current application. |
GOOGLE_CLOUD_PROJECT | The Project ID associated with your application, which is visible in the Google Cloud console |
PORT | The port that will receive HTTP requests. |
RACK_ENV | Set toproduction. |
RAILS_ENV | Set toproduction. |
RAILS_SERVE_STATIC_FILES | Set totrue. |
You can set additional environment variables withapp.yaml.
Metadata server
Each instance of your application can use theCompute Engine metadata serverto query information about the instance, including its hostname, externalIP address, instance ID, custom metadata, and service account information.App Engine doesn't allow you to set custom metadata for each instance, but youcan setproject-wide custom metadataand read it from your App Engine and Compute Engine instances.
This example function uses the metadata server to get an external IP address ofan instance.
require"sinatra"require"net/http"get"/"douri=URI.parse("http://metadata.google.internal/computeMetadata/v1"+"/instance/network-interfaces/0/access-configs/0/external-ip")request=Net::HTTP::Get.newuri.pathrequest.add_field"Metadata-Flavor","Google"http=Net::HTTP.newuri.host,uri.portresponse=http.requestrequest"External IP:#{response.body}"endExcept as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.