.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GEMFILE" "5" "April 2014" "" ""
.
.SH "NAME"
\fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
.
.SH "SYNOPSIS"
A \fBGemfile\fR describes the gem dependencies required to execute associated Ruby code\.
.
.P
Place the \fBGemfile\fR in the root of the directory containing the associated code\. For instance, in a Rails application, place the \fBGemfile\fR in the same directory as the \fBRakefile\fR\.
.
.SH "SYNTAX"
A \fBGemfile\fR is evaluated as Ruby code, in a context which makes available a number of methods used to describe the gem requirements\.
.
.SH "SOURCES (#source)"
At the top of the \fBGemfile\fR, add one line for each \fBRubygems\fR source that might contain the gems listed in the \fBGemfile\fR\.
.
.IP "" 4
.
.nf

source "https://rubygems\.org"
source "http://gems\.github\.com"
.
.fi
.
.IP "" 0
.
.P
Each of these _source_s \fBMUST\fR be a valid Rubygems repository\. Sources are checked for gems following the heuristics described in \fISOURCE PRIORITY\fR\.
.
.SH "RUBY (#ruby)"
If your application requires a specific Ruby version or engine, specify your requirements using the \fBruby\fR method, with the following arguments\. All parameters are \fBOPTIONAL\fR unless otherwise specified\.
.
.SS "VERSION (required)"
The version of Ruby that your application requires\. If your application requires an alternate Ruby engine, such as JRuby or Rubinius, this should be the Ruby version that the engine is compatible with\.
.
.IP "" 4
.
.nf

ruby "1\.9\.3"
.
.fi
.
.IP "" 0
.
.SS "ENGINE (:engine)"
Each application \fImay\fR specify a Ruby engine\. If an engine is specified, an engine version \fImust\fR also be specified\.
.
.SS "ENGINE VERSION (:engine_version)"
Each application \fImay\fR specify a Ruby engine version\. If an engine version is specified, an engine \fImust\fR also be specified\. If the engine is "ruby" the engine version specified \fImust\fR match the Ruby version\.
.
.IP "" 4
.
.nf

ruby "1\.8\.7", :engine => "jruby", :engine_version => "1\.6\.7"
.
.fi
.
.IP "" 0
.
.SS "PATCHLEVEL (:patchlevel)"
Each application \fImay\fR specify a Ruby patchlevel\.
.
.IP "" 4
.
.nf

ruby "2\.0\.0", :patchlevel => "247"
.
.fi
.
.IP "" 0
.
.SH "GEMS (#gem)"
Specify gem requirements using the \fBgem\fR method, with the following arguments\. All parameters are \fBOPTIONAL\fR unless otherwise specified\.
.
.SS "NAME (required)"
For each gem requirement, list a single \fIgem\fR line\.
.
.IP "" 4
.
.nf

gem "nokogiri"
.
.fi
.
.IP "" 0
.
.SS "VERSION"
Each \fIgem\fR \fBMAY\fR have one or more version specifiers\.
.
.IP "" 4
.
.nf

gem "nokogiri", ">= 1\.4\.2"
gem "RedCloth", ">= 4\.1\.0", "< 4\.2\.0"
.
.fi
.
.IP "" 0
.
.SS "REQUIRE AS (:require)"
Each \fIgem\fR \fBMAY\fR specify files that should be used when autorequiring via \fBBundler\.require\fR\. You may pass an array with multiple files or \fBtrue\fR if file you want \fBrequired\fR has same name as \fIgem\fR or \fBfalse\fR to prevent any file from being autorequired\.
.
.IP "" 4
.
.nf

gem "redis", :require => ["redis/connection/hiredis", "redis"]
gem "webmock", :require => false
gem "debugger", :require => true
.
.fi
.
.IP "" 0
.
.P
The argument defaults to the name of the gem\. For example, these are identical:
.
.IP "" 4
.
.nf

gem "nokogiri"
gem "nokogiri", :require => "nokogiri"
gem "nokogiri", :require => true
.
.fi
.
.IP "" 0
.
.SS "GROUPS (:group or :groups)"
Each \fIgem\fR \fBMAY\fR specify membership in one or more groups\. Any \fIgem\fR that does not specify membership in any group is placed in the \fBdefault\fR group\.
.
.IP "" 4
.
.nf

gem "rspec", :group => :test
gem "wirble", :groups => [:development, :test]
.
.fi
.
.IP "" 0
.
.P
The Bundler runtime allows its two main methods, \fBBundler\.setup\fR and \fBBundler\.require\fR, to limit their impact to particular groups\.
.
.IP "" 4
.
.nf

# setup adds gems to Ruby\'s load path
Bundler\.setup                    # defaults to all groups
require "bundler/setup"          # same as Bundler\.setup
Bundler\.setup(:default)          # only set up the _default_ group
Bundler\.setup(:test)             # only set up the _test_ group (but `not` _default_)
Bundler\.setup(:default, :test)   # set up the _default_ and _test_ groups, but no others

# require requires all of the gems in the specified groups
Bundler\.require                  # defaults to just the _default_ group
Bundler\.require(:default)        # identical
Bundler\.require(:default, :test) # requires the _default_ and _test_ groups
Bundler\.require(:test)           # requires just the _test_ group
.
.fi
.
.IP "" 0
.
.P
The Bundler CLI allows you to specify a list of groups whose gems \fBbundle install\fR should not install with the \fB\-\-without\fR option\. To specify multiple groups to ignore, specify a list of groups separated by spaces\.
.
.IP "" 4
.
.nf

bundle install \-\-without test
bundle install \-\-without development test
.
.fi
.
.IP "" 0
.
.P
After running \fBbundle install \-\-without test\fR, bundler will remember that you excluded the test group in the last installation\. The next time you run \fBbundle install\fR, without any \fB\-\-without option\fR, bundler will recall it\.
.
.P
Also, calling \fBBundler\.setup\fR with no parameters, or calling \fBrequire "bundler/setup"\fR will setup all groups except for the ones you excluded via \fB\-\-without\fR (since they are obviously not available)\.
.
.P
Note that on \fBbundle install\fR, bundler downloads and evaluates all gems, in order to create a single canonical list of all of the required gems and their dependencies\. This means that you cannot list different versions of the same gems in different groups\. For more details, see Understanding Bundler \fIhttp://bundler\.io/rationale\.html\fR\.
.
.SS "PLATFORMS (:platforms)"
If a gem should only be used in a particular platform or set of platforms, you can specify them\. Platforms are essentially identical to groups, except that you do not need to use the \fB\-\-without\fR install\-time flag to exclude groups of gems for other platforms\.
.
.P
There are a number of \fBGemfile\fR platforms:
.
.TP
\fBruby\fR
C Ruby (MRI) or Rubinius, but \fBNOT\fR Windows
.
.TP
\fBruby_18\fR
\fIruby\fR \fBAND\fR version 1\.8
.
.TP
\fBruby_19\fR
\fIruby\fR \fBAND\fR version 1\.9
.
.TP
\fBruby_20\fR
\fIruby\fR \fBAND\fR version 2\.0
.
.TP
\fBruby_21\fR
\fIruby\fR \fBAND\fR version 2\.1
.
.TP
\fBmri\fR
Same as \fIruby\fR, but not Rubinius
.
.TP
\fBmri_18\fR
\fImri\fR \fBAND\fR version 1\.8
.
.TP
\fBmri_19\fR
\fImri\fR \fBAND\fR version 1\.9
.
.TP
\fBmri_20\fR
\fImri\fR \fBAND\fR version 2\.0
.
.TP
\fBmri_21\fR
\fImri\fR \fBAND\fR version 2\.1
.
.TP
\fBrbx\fR
Same as \fIruby\fR, but only Rubinius (not MRI)
.
.TP
\fBjruby\fR
JRuby
.
.TP
\fBmswin\fR
Windows
.
.TP
\fBmingw\fR
Windows 32 bit \'mingw32\' platform (aka RubyInstaller)
.
.TP
\fBmingw_18\fR
\fImingw\fR \fBAND\fR version 1\.8
.
.TP
\fBmingw_19\fR
\fImingw\fR \fBAND\fR version 1\.9
.
.TP
\fBmingw_20\fR
\fImingw\fR \fBAND\fR version 2\.0
.
.TP
\fBmingw_21\fR
\fImingw\fR \fBAND\fR version 2\.1
.
.TP
\fBx64_mingw\fR
Windows 64 bit \'mingw32\' platform (aka RubyInstaller x64)
.
.TP
\fBx64_mingw_20\fR
\fIx64_mingw\fR \fBAND\fR version 2\.0
.
.TP
\fBx64_mingw_21\fR
\fIx64_mingw\fR \fBAND\fR version 2\.1
.
.P
As with groups, you can specify one or more platforms:
.
.IP "" 4
.
.nf

gem "weakling",   :platforms => :jruby
gem "ruby\-debug", :platforms => :mri_18
gem "nokogiri",   :platforms => [:mri_18, :jruby]
.
.fi
.
.IP "" 0
.
.P
All operations involving groups (\fBbundle install\fR, \fBBundler\.setup\fR, \fBBundler\.require\fR) behave exactly the same as if any groups not matching the current platform were explicitly excluded\.
.
.SS "GIT (:git)"
If necessary, you can specify that a gem is located at a particular git repository\. The repository can be public (\fBhttp://github\.com/rails/rails\.git\fR) or private (\fBgit@github\.com:rails/rails\.git\fR)\. If the repository is private, the user that you use to run \fBbundle install\fR \fBMUST\fR have the appropriate keys available in their \fB$HOME/\.ssh\fR\.
.
.P
Git repositories are specified using the \fB:git\fR parameter\. The \fBgroup\fR, \fBplatforms\fR, and \fBrequire\fR options are available and behave exactly the same as they would for a normal gem\.
.
.IP "" 4
.
.nf

gem "rails", :git => "git://github\.com/rails/rails\.git"
.
.fi
.
.IP "" 0
.
.P
A git repository \fBSHOULD\fR have at least one file, at the root of the directory containing the gem, with the extension \fB\.gemspec\fR\. This file \fBMUST\fR contain a valid gem specification, as expected by the \fBgem build\fR command\.
.
.P
If a git repository does not have a \fB\.gemspec\fR, bundler will attempt to create one, but it will not contain any dependencies, executables, or C extension compilation instructions\. As a result, it may fail to properly integrate into your application\.
.
.P
If a git repository does have a \fB\.gemspec\fR for the gem you attached it to, a version specifier, if provided, means that the git repository is only valid if the \fB\.gemspec\fR specifies a version matching the version specifier\. If not, bundler will print a warning\.
.
.IP "" 4
.
.nf

gem "rails", "2\.3\.8", :git => "git://github\.com/rails/rails\.git"
# bundle install will fail, because the \.gemspec in the rails
# repository\'s master branch specifies version 3\.0\.0
.
.fi
.
.IP "" 0
.
.P
If a git repository does \fBnot\fR have a \fB\.gemspec\fR for the gem you attached it to, a version specifier \fBMUST\fR be provided\. Bundler will use this version in the simple \fB\.gemspec\fR it creates\.
.
.P
Git repositories support a number of additional options\.
.
.TP
\fBbranch\fR, \fBtag\fR, and \fBref\fR
You \fBMUST\fR only specify at most one of these options\. The default is \fB:branch => "master"\fR
.
.TP
\fBsubmodules\fR
Specify \fB:submodules => true\fR to cause bundler to expand any submodules included in the git repository
.
.P
If a git repository contains multiple \fB\.gemspecs\fR, each \fB\.gemspec\fR represents a gem located at the same place in the file system as the \fB\.gemspec\fR\.
.
.IP "" 4
.
.nf

|~rails                   [git root]
| |\-rails\.gemspec         [rails gem located here]
|~actionpack
| |\-actionpack\.gemspec    [actionpack gem located here]
|~activesupport
| |\-activesupport\.gemspec [activesupport gem located here]
|\.\.\.
.
.fi
.
.IP "" 0
.
.P
To install a gem located in a git repository, bundler changes to the directory containing the gemspec, runs \fBgem build name\.gemspec\fR and then installs the resulting gem\. The \fBgem build\fR command, which comes standard with Rubygems, evaluates the \fB\.gemspec\fR in the context of the directory in which it is located\.
.
.SS "GITHUB (:github)"
If the git repository you want to use is hosted on GitHub and is public, you can use the :github shorthand to specify just the github username and repository name (without the trailing "\.git"), separated by a slash\. If both the username and repository name are the same, you can omit one\.
.
.IP "" 4
.
.nf

gem "rails", :github => "rails/rails"
gem "rails", :github => "rails"
.
.fi
.
.IP "" 0
.
.P
Are both equivalent to
.
.IP "" 4
.
.nf

gem "rails", :git => "git://github\.com/rails/rails\.git"
.
.fi
.
.IP "" 0
.
.P
In addition, if you wish to choose a specific branch:
.
.IP "" 4
.
.nf

gem "rails", :github => "rails/rails", :branch => "branch_name"
.
.fi
.
.IP "" 0
.
.SS "PATH (:path)"
You can specify that a gem is located in a particular location on the file system\. Relative paths are resolved relative to the directory containing the \fBGemfile\fR\.
.
.P
Similar to the semantics of the \fB:git\fR option, the \fB:path\fR option requires that the directory in question either contains a \fB\.gemspec\fR for the gem, or that you specify an explicit version that bundler should use\.
.
.P
Unlike \fB:git\fR, bundler does not compile C extensions for gems specified as paths\.
.
.IP "" 4
.
.nf

gem "rails", :path => "vendor/rails"
.
.fi
.
.IP "" 0
.
.SH "BLOCK FORM OF GIT, PATH, GROUP and PLATFORMS"
The \fB:git\fR, \fB:path\fR, \fB:group\fR, and \fB:platforms\fR options may be applied to a group of gems by using block form\.
.
.IP "" 4
.
.nf

git "git://github\.com/rails/rails\.git" do
  gem "activesupport"
  gem "actionpack"
end

platforms :ruby do
  gem "ruby\-debug"
  gem "sqlite3"
end

group :development do
  gem "wirble"
  gem "faker"
end
.
.fi
.
.IP "" 0
.
.P
In the case of the \fBgit\fR block form, the \fB:ref\fR, \fB:branch\fR, \fB:tag\fR, and \fB:submodules\fR options may be passed to the \fBgit\fR method, and all gems in the block will inherit those options\.
.
.SH "GEMSPEC (#gemspec)"
If you wish to use Bundler to help install dependencies for a gem while it is being developed, use the \fBgemspec\fR method to pull in the dependencies listed in the \fB\.gemspec\fR file\.
.
.P
The \fBgemspec\fR method adds any runtime dependencies as gem requirements in the default group\. It also adds development dependencies as gem requirements in the \fBdevelopment\fR group\. Finally, it adds a gem requirement on your project (\fB:path => \'\.\'\fR)\. In conjunction with \fBBundler\.setup\fR, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths\.
.
.P
The \fBgemspec\fR method supports optional \fB:path\fR, \fB:name\fR, and \fB:development_group\fR options, which control where bundler looks for the \fB\.gemspec\fR, what named \fB\.gemspec\fR it uses (if more than one is present), and which group development dependencies are included in\.
.
.SH "SOURCE PRIORITY"
When attempting to locate a gem to satisfy a gem requirement, bundler uses the following priority order:
.
.IP "1." 4
The source explicitly attached to the gem (using \fB:path\fR or \fB:git\fR)
.
.IP "2." 4
For implicit gems (dependencies of explicit gems), any git or path repository otherwise declared\. This results in bundler prioritizing the ActiveSupport gem from the Rails git repository over ones from \fBrubygems\.org\fR
.
.IP "3." 4
The sources specified via \fBsource\fR, searching each source in your \fBGemfile\fR from last added to first added\.
.
.IP "" 0

