Ruby Buildpack

Page last updated:

Push Apps

Cloud Foundry uses the Ruby buildpack if your app has a Gemfile and Gemfile.lock in the root directory. The Ruby buildpack uses Bundler to install your dependencies.

If your Cloud Foundry deployment does not have the Ruby buildpack installed or the installed version is out of date, push your app with the -b option to specify the buildpack:

$ cf push MY-APP -b https://github.com/cloudfoundry/ruby-buildpack.git

For more detailed information about deploying Ruby applications see the following topics:

You can find the source for the Ruby buildpack in the Ruby buildpack repository on GitHub.

Supported Versions

You can find supported Ruby versions in the release notes for the Ruby buildpack on GitHub.

Specify a Ruby Version

Specify specific versions of the Ruby runtime in the Gemfile for your app as described in the sections below.

MRI

For MRI, specify the version of Ruby in your Gemfile as follows:

ruby '~> 2.2.3'

With this example declaration in the Gemfile, if Ruby versions 2.2.4, 2.2.5, and 2.3.0 are present in the Ruby buildpack, the app uses Ruby version 2.2.5.

For more information about the ruby directive for Bundler Gemfiles, see the Bundler documentation.

Note: If you use v1.6.18 or earlier, you must specify an exact version, such as ruby '2.2.3'. In Ruby Buildpack v1.6.18 and earlier, Rubygems do not support version operators for the ruby directive.

JRuby

For JRuby, specify the version of Ruby in your Gemfile based on the version of JRuby your app uses.

JRuby version 1.7.x supports either 1.9 mode or 2.0 mode.

  • For 1.9 mode, use the following: ruby ruby '1.9.3', :engine => 'jruby', :engine_version => '1.7.25'
  • For 2.0 mode, use the following: ruby ruby '2.0.0', :engine => 'jruby', :engine_version => '1.7.25'

For Jruby version >= 9.0, use the following: ruby ruby '2.2.3', :engine => 'jruby', :engine_version => '9.0.5.0'

The Ruby buildpack only supports the stable Ruby versions listed in the manifest.yml and release notes for the Ruby buildpack on GitHub.

If you try to use a binary that is not supported, staging your app fails with the following error message:

Could not get translated url, exited with: DEPENDENCY_MISSING_IN_MANIFEST: ...
 !
 !     exit
 !
Staging failed: Buildpack compilation step failed

Note: The Ruby buildpack does not support he pessimistic version operator `~>` on the Gemfile `ruby` directive for JRuby.

Vendor App Dependencies

As stated in the Disconnected Environments documentation, your application must ‘vendor’ its dependencies.

For the Ruby buildpack, use the bundle package --all command in Bundler to vendor the dependencies.

Example:

$ cd my-app-directory
bundle package --all

The cf push command uploads your vendored dependencies. The Ruby buildpack compiles any dependencies requiring compilation while staging your app.

Buildpack Logging and Application Logging

The Ruby buildpack only runs during the staging process, and only logs what is important to staging, such as what is being downloaded, what the configuration is, and work that the buildpack does on your application.

The buildpack stops logging when the staging process finishes. The Loggregator handles application logging.

Your application must write to STDOUT or STDERR for its logs to be included in the Loggregator stream. For more information, see the Application Logging in Cloud Foundry topic.

If you are deploying a Rails application, the buildpack may or may not automatically install the necessary plugin or gem for logging, depending on the Rails version of the application:

  • Rails 2.x: The buildpack automatically installs the rails_log_stdout plugin into the application. For more information about the rails_log_stdout plugin, refer to the Github README.

  • Rails 3.x: The buildpack automatically installs the rails_12factor gem if it is not present and issues a warning message. You must add the rails_12factor gem to your Gemfile to quiet the warning message. For more information about the rails_12factor gem, refer to the Github README.

  • Rails 4.x: The buildpack only issues a warning message that the rails_12factor gem is not present, but does not install the gem. You must add the rails_12factor gem to your Gemfile to quiet the warning message. For more information about the rails_12factor gem, refer to the Github README.

For more information about the rails_12factor gem, refer to the Github README.

Proxy Support

If you need to use a proxy to download dependencies during staging, you can set the http_proxy and/or https_proxy environment variables. For more information, see the Proxy Usage Docs.

BOSH Configured Custom Trusted Certificate Support

Ruby uses certificates stored in /etc/ssl/certs. Your platform operator can configure the platform to add the custom certificates into the app container.

Help and Support

Join the #buildpacks channel in our Slack community if you need any further assistance.

For more information about using and extending the Ruby buildpack in Cloud Foundry, see the Ruby buildpack repository on GitHub.

You can find current information about the Ruby buildpack in the release notes for the Ruby buildpack on GitHub.

Create a pull request or raise an issue on the source for this page in GitHub