Permalink
Fetching contributors…
Cannot retrieve contributors at this time
141 lines (88 sloc) 7.17 KB
---
title: Ruby Buildpack
owner: Buildpacks
---
<strong><%= modified_date %></strong>
## <a id='pushing_apps'></a> 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:
<pre class="terminal">
$ cf push MY-APP -b https://github.com/cloudfoundry/ruby-buildpack.git
</pre>
For more detailed information about deploying Ruby applications see the following topics:
* <a href="./ruby-tips.html" class="subnav">Tips for Ruby Developers</a>
* <a href="./deploying-apps-index.html" class="subnav">Getting Started Deploying Apps</a>
* <a href="./rake-config.html" class="subnav">Configuring Rake Tasks for Deployed Apps</a>
* <a href="./ruby-environment.html" class="subnav">Environment Variables Defined by the Ruby Buildpack</a>
* <a href="./ruby-service-bindings.html" class="subnav">Configuring Service Connections for Ruby</a>
* <a href="./windows.html" class="subnav">Support for Windows Gemfiles</a>
You can find the source for the Ruby buildpack in the [Ruby buildpack repository](https://github.com/cloudfoundry/cf-buildpack-ruby) on GitHub.
## <a id='supported_versions'></a>Supported Versions ##
You can find supported Ruby versions in the [release notes for the Ruby buildpack](https://github.com/cloudfoundry/ruby-buildpack/releases) on GitHub.
## <a id='runtime'></a>Specify a Ruby Version ##
Specify specific versions of the Ruby runtime in the `Gemfile` for your app as described in the sections below.
### <a id='mri_runtime'></a>MRI ###
For MRI, specify the version of Ruby in your `Gemfile` as follows:
``` ruby
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](http://bundler.io/gemfile_ruby.html).
<p class="note"><strong>Note</strong>: If you use v1.6.18 or earlier, you must specify an exact version, such as <code>ruby '2.2.3'</code>.
In <a href="https://github.com/cloudfoundry/ruby-buildpack/releases/tag/v1.6.18">Ruby Buildpack v1.6.18</a> and earlier, Rubygems do not support version operators for the <code>ruby</code> directive. </p>
### <a id='jruby_runtime'></a>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](https://github.com/cloudfoundry/ruby-buildpack/releases) 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
```
<p class="note"><strong>Note</strong>: The Ruby buildpack does not support he pessimistic version operator <code>~></code> on the Gemfile <code>ruby</code> directive for JRuby.</p>
## <a id='vendoring'></a>Vendor App Dependencies ##
As stated in the [Disconnected Environments documentation](https://github.com/cf-buildpacks/buildpack-packager/blob/master/doc/disconnected_environments.md), your application must 'vendor' its dependencies.
For the Ruby buildpack, use the `bundle package --all` command in Bundler to vendor the dependencies.
Example:
```shell
$ 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.
## <a id='logging'></a>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](../../devguide/deploy-apps/streaming-logs.html) 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](https://github.com/ddollar/rails_log_stdout).
* 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](https://github.com/heroku/rails_12factor).
* 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](https://github.com/heroku/rails_12factor).
For more information about the `rails_12factor` gem, refer to the [Github README](https://github.com/heroku/rails_12factor).
## <a id='proxy_support'></a> 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](http://docs.cloudfoundry.org/buildpacks/proxy-usage.html).
## <a id='bosh_trusted_cert'></a>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.
<% if vars.product_name == "CF" %>
<%= partial "../link-configure-trusted-certificates" %>
<% end %>
## <a id='help_support'></a>Help and Support ##
Join the #buildpacks channel in our [Slack community] (http://slack.cloudfoundry.org/) if you need any further assistance.
For more information about using and extending the Ruby buildpack in Cloud Foundry, see the [Ruby buildpack repository](https://github.com/cloudfoundry/cf-buildpack-ruby) on GitHub.
You can find current information about the Ruby buildpack in the [release notes for the Ruby buildpack](https://github.com/cloudfoundry/ruby-buildpack/releases) on GitHub.