The Ruby runtime

Your Cloud Run function runs in an environment consisting of anoperating system version with add-on packages, language support, andtheRuby Functions Frameworklibrary that supports and invokes your function. Thisenvironment is identified by the language version, and is known as theruntime ID.

Function preparation

You can prepare a function directly from the Google Cloud console or write it onyour local machine and upload it. To prepare your local machine for Rubydevelopment, seeSet up a Ruby development environment.

Supported Ruby runtimes and base images

RuntimeRuntime IDStacksRuntime base image
Ruby 3.4ruby34
  • google-22 (default)
  • google-22-full
  • google-22/ruby34
  • google-22-full/ruby34
  • Ruby 3.3ruby33
  • google-22 (default)
  • google-22-full
  • google-22/ruby33
  • google-22-full/ruby33
  • Ruby 3.2ruby32
  • google-22 (default)
  • google-22-full
  • google-22/ruby32
  • google-22-full/ruby32
  • Ruby 3.0ruby30 google-18-fullgoogle-18-full/ruby30
    Ruby 2.7ruby27 google-18-fullgoogle-18-full/ruby27
    Ruby 2.6ruby26 google-18-fullgoogle-18-full/ruby26

    Select your runtime

    You can select one of the supported Ruby runtimes for your function duringdeployment.

    You can select a runtime version using the Google Cloud console, or thegcloud CLI. Click the tab for instructions on using the tool ofyour choice:

    gcloud

    Specify theRuby base image for your function using the--base-image flag,while deploying your function. For example:

    gcloud run deployFUNCTION \    --source . \    --functionFUNCTION_ENTRYPOINT \    --base-image ruby34

    Replace:

    • FUNCTION with the name of the function you aredeploying. You can omit this parameter entirely,but you will be prompted for the name if you omit it.

    • FUNCTION_ENTRYPOINT with the entry point to your function inyour source code. This is the code Cloud Run executes when yourfunction runs. The value of this flag must be a function name orfully-qualified class name that exists in your source code.

    For detailed instructions on deploying a function using the gcloud CLI, seeDeploy functions in Cloud Run.

    Console

    You can select a runtime version when you create or update a Cloud Run function in the Google Cloud console. For detailedinstructions on deploying a function, seeDeploy functions in Cloud Run.

    To select a runtime in the Google Cloud console when you create a function, follow these steps:

    1. In the Google Cloud console, go to the Cloud Run page:

      Go to Cloud Run

    2. ClickWrite a function.

    3. In theRuntime list, select a Ruby runtime version.

    4. ClickCreate, and wait for Cloud Run to create the serviceusing a placeholder revision.

    5. The console will redirect you to theSourcetab where you can see the source code of your function. ClickSave and redeploy.

    For detailed instructions on updating the runtime version after your function isdeployed, seeRe-deploy new source code.

    Source code structure

    For Cloud Run functions to find your function's definition, yoursource code must follow a specific structure. SeeWrite Cloud Run functions formore information.

    Specify dependencies

    Cloud Run functions written in Ruby usebundler to access dependencies.

    TheFunctions Frameworkis a required dependency for all functions. AlthoughCloud Run functions installs it on your behalf when the functionis created, we recommend that you include it as an explicit dependency forclarity.

    If yourfunction relies on private dependencies, we recommend that youmirrorfunctions-framework to your private registry. Include the mirroredfunctions-framework as a dependency to your function to avoid installing thepackage from the public internet.

    Each function must provide aGemfile that specifies thefunctions_frameworkgem, along with any additional gems needed by the function.Gemfile must be inthe same directory as theapp.rb file that contains your function code. Inaddition, your function must provide a lockfile that specifies all thetransitive dependencies and their exact versions. This file,Gemfile.lock, isalso located in the same directory alongside theGemfile.

    When you deploy your function, Cloud Run downloads and installsthe dependencies declared in theGemfile andGemfile.lock usingbundler.

    TheGemfile lists the packages required by your function, along with anyoptional version constraints. For more details, see theGemfile reference.

    The following is an exampleGemfile:

    source "https://rubygems.org"gem "functions_framework", "~> 0.7"gem "google-cloud-storage", "~> 1.29"

    Packaging local dependencies

    You can also package and deploy dependencies alongside alongside your function.This approach is useful if your dependency is not available using therubygems package manager.

    To package a gem locally, include it in a directory in your function's directorystructure, and provide the path in the dependency'sGemfile entry. The gemdirectory must include a validgemspec file, and it must be located within thefunction's directory hierarchy so that its code is deployed along with yourfunction. For example, you might use a directory structure such as thefollowing:

    myfunction/├── Gemfile├── Gemfile.lock├── app.rb└── my_private_gem/    ├── lib/    |   └── my_private_gem.rb    └── my_private_gem.gemspec

    TheGemfile entry might look like this:

    source "https://rubygems.org"gem "functions_framework", "~> 0.7"gem "my_private_gem", path: "./my_private_gem"

    See theGemfile reference for more discussionabout referencing local gem paths.

    Except 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 2026-02-19 UTC.