## Specifying Versions of Ruby

The buildpacks project provides support for the current release and Active LTS release of Ruby. Older releases of Ruby are available but may not be actively maintained by the project.

### Using `Gemfile.lock`

If your application uses bundler, you should have Gemfile.lock at the root of your repo. Ruby buildpacks will automatically use a version that's locked in your Gemfile.lock.
For example, if your Gemfile.lock has the following:

    RUBY VERSION
      ruby 3.0.3p0

The buildpacks will automatically use Ruby 3.0.3, with the latest patch level.

### Using `GOOGLE_RUNTIME_VERSION`

If you're not using bundler, you can specify a ruby version using the environment variable as follows:

    pack build --builder=gcr.io/buildpacks/builder \
       sample-ruby \
       --env GOOGLE_RUNTIME_VERSION=3.0.3


You can also use a `project.toml` project descriptor to encode
the environment variable alongside your project files. See instructions on
[building the application with environment variables](https://docs.cloud.google.com/docs/buildpacks/set-environment-variables#build_the_application_with_environment_variables)).

If you're using bundler,`GOOGLE_RUNTIME_VERSION` can't be used to override the specified version in Gemfile.lock
under `RUBY VERSION`.

## Installing Dependencies

### Using Bundler

- [Bundler](https://bundler.io) is the default package manager
- Commit `Gemfile.lock` to your repo since we use the lock file to build the app
- By default only production dependencies are installed

### Bundler Version

Bundler has known [compatibility issues](https://bundler.io/compatibility).
If your application uses bundler, due to various compatibility issues with Ruby and Rubygems, we update
the Gemfile.lock in the built app to use one of the two supported versions.
All applications using bundler 1.\* and 2.\* in `BUNDLED WITH` are normalized to use bundler 1.17.3 and 2.3.15.

## Specifying an Entrypoint

### Using Procfile

You can specify an entrypoint, a command that runs when the container starts, using Procfile.
For example, with the following in your Procfile at the root of your app:

    web: ruby main.rb

The Ruby buildpack will use the command `ruby main.rb` as the entrypoint of the built container.
By default the `web` target from the Procfile is used.

To use a different entrypoint, you can specify a different target from your
Procfile as an argument.

With a Procfile containing the following:
`web: ruby main.rb
custom: ruby custom.rb`

You can use the custom Procfile target by passing it as an argument:
`bash
pack build --builder=gcr.io/buildpacks/builder \
sample-ruby \
--entrypoint=custom`

### Using `GOOGLE_ENTRYPOINT`

If you're not using a Procfile or want to override the Procfile, you can specify an entrypoint
using the `GOOGLE_ENTRYPOINT` environment variable. Here's an example:

    pack build --builder=gcr.io/buildpacks/builder \
       sample-ruby \
       --env GOOGLE_ENTRYPOINT="ruby custom.rb"

## Environment Variables

The Ruby buildpack supports the following environment variables to customize your container

### BUNDLE_

See `bundler` [documentation](https://bundler.io/v2.0/man/bundle-config.1.html).

**Example:** `BUNDLE_TIMEOUT=60` sets `--timeout=60` for `bundle` commands.