GEMFILE(5) File Formats Manual GEMFILE(5) (NAME) gemfile - (SYNOPSIS) Gemfile (gem) . Gemfile . Rails Gemfile Rakefile . (SYNTAX) Gemfile . (GLOBAL SOURCE) Gemfile RubyGems Gemfile . source "https://rubygems.org" . Bundler 1.13 . source MUST () RubyGems . RubyGems source . (SOURCE PRIORITY) . Bundler 1.13: Bundler . :source source . (CREDENTIALS) . bundle config(1) bundle-config.1.html . Gemfile . bundle config gems.example.com user:password Gemfury Gemfile . source "https://user:password@gems.example.com" URL config . (RUBY) ruby . OPTIONAL () . (VERSION - ) . JRuby TruffleRuby . ruby "3.1.2" ( .ruby-version) file . ruby file: ".ruby-version" : o 3.1.2 (.ruby-version) o ruby 3.1.2 (.tool-versions : https://asdf-vm.com/manage/configuration.html#tool-versions) (ENGINE) may () . must () . o . o : https://en.wikipedia.org/wiki/Ruby_MRI MRI . Matz . MRI CRuby C . MRI . o https://www.ruby-lang.org/en/about . JRuby https://www.jruby.org TruffleRuby https://www.graalvm.org/ruby . Rubinius . JRuby JVM ( Java Virtual Machine) . TruffleRuby GraalVM JVM . (ENGINE VERSION) may () . must () . "ruby" must () . ruby "2.6.8", engine: "jruby", engine_version: "9.3.8.0" (PATCHLEVEL) may () . Ruby 2.1.0 (major) (minor) (teeny) . Bundler 1.4.0 Ruby 2.0 . ruby "3.1.2", patchlevel: "20" (GEMS) gem . OPTIONAL () . (NAME - ) gem . gem "nokogiri" (VERSION) gem MAY () . gem "nokogiri", ">= 1.4.2" gem "RedCloth", ">= 4.1.0", "< 4.2.0" (REQUIRE AS) gem MAY () Bundler.require . true require gem false . gem "redis", require: ["redis/connection/hiredis", "redis"] gem "webmock", require: false gem "byebug", require: true . : gem "nokogiri" gem "nokogiri", require: "nokogiri" gem "nokogiri", require: true (GROUPS) gem MAY () . gem default . gem "rspec", group: :test gem "wirble", groups: [:development, :test] Bundler Bundler.setup Bundler.require . # setup load path Bundler.setup # require "bundler/setup" # Bundler.setup Bundler.setup(:default) # (_default_) Bundler.setup(:test) # (_test_) ( _default_) Bundler.setup(:default, :test) # _default_ _test_ # require Bundler.require # _default_ Bundler.require(:default) # Bundler.require(:default, :test) # _default_ _test_ Bundler.require(:test) # _test_ Bundler bundle install without . . bundle config set --local without test bundle config set --local without development test Bundler.setup require "bundler/setup" --without ( ). bundle install . . Bundler https://bundler.io/rationale.html . score (PLATFORMS) . --without . Gemfile : ruby C Ruby (MRI) Rubinius TruffleRuby Windows mri C Ruby (MRI) Windows windows Windows C Ruby (MRI) RubyInstaller mswin Windows C Ruby (MRI) RubyInstaller mswin64 Windows C Ruby (MRI) RubyInstaller rbx Rubinius jruby JRuby truffleruby TruffleRuby ruby mri mswin mswin64 windows . ruby 3.1 : ruby_31 ( ) : gem "weakling", platforms: :jruby gem "ruby-debug", platforms: :mri_31 gem "nokogiri", platforms: [:windows_31, :jruby] (bundle install bundle-install.1.html Bundler.setup Bundler.require) . windows : o mswin mswin64 mingw32 x64_mingw bundle lock --add-platform . " " bundle lock --add-platform lockfile . FORCE_RUBY_PLATFORM (pure ruby) force_ruby_platform : gem "ffi", force_ruby_platform: true ( ): o . o ( required_ruby_version ) Gemfile{.lock} . (SOURCE) ':source' RubyGems . gem "some_internal_gem", source: "https://gems.example.com" . . . Bundler 1.13: (GLOBAL SOURCE) . :source . Gemfile . (GIT) :git . : HTTP(S) gem "rails", git: "https://github.com/rails/rails.git" SSH gem "rails", git: "git@github.com:rails/rails.git" git gem "rails", git: "git://github.com/rails/rails.git" SSH bundle install MUST () $HOME/.ssh . : http:// git:// . (man-in-the-middle) . HTTPS SSH . group platforms require . SHOULD ( ) .gemspec . MUST () gem build . .gemspec C . . .gemspec ( ) .gemspec . . gem "rails", "2.3.8", git: "https://github.com/rails/rails.git" # bundle install .gemspec # master rails 3.0.0 .gemspec MUST () . .gemspec . . branch tag ref MUST () . branch: "master" . : gem "rails", git: "https://github.com/rails/rails.git", branch: "5-0-stable" gem "rails", git: "https://github.com/rails/rails.git", tag: "v5.0.0" gem "rails", git: "https://github.com/rails/rails.git", ref: "4aded" submodules https://git-scm.com/book/en/v2/Git-Tools-Submodules . submodules: true . .gemspec .gemspec .gemspec . |~rails [ ] | |-rails.gemspec [ rails ] |~actionpack | |-actionpack.gemspec [ actionpack ] |~activesupport | |-activesupport.gemspec [ activesupport ] |... gemspec gem build name.gemspec . gem build Rubygems .gemspec . (GIT SOURCE) git_source . : git_source(:stash){ |repo_name| "https://stash.corp.acme.pl/#{repo_name}.git" } gem 'rails', stash: 'forks/rails' : gem "rails", stash: "forks/rails", branch: "branch_name" (GITHUB) : Bundler 2.0 git:// . . GitHub :github ( ".git") . . gem "rails", github: "rails/rails" gem "rails", github: "rails" gem "rails", git: "https://github.com/rails/rails.git" github git_source :branch . Pull Request : gem "rails", github: "https://github.com/rails/rails/pull/43753" : gem "rails", github: "rails/rails", branch: "refs/pull/43753/head" (GIST) GitHub Gist :gist gist ( ".git") . gem "the_hatch", gist: "4815162342" : gem "the_hatch", git: "https://gist.github.com/4815162342.git" gist git_source :branch . (BITBUCKET) Bitbucket :bitbucket ( ".git") . . gem "rails", bitbucket: "rails/rails" gem "rails", bitbucket: "rails" gem "rails", git: "https://rails@bitbucket.org/rails/rails.git" bitbucket git_source :branch . (PATH) . Gemfile . :git :path .gemspec . :git C . gem "rails", path: "vendor/rails" path . gemspec . path 'components' do gem 'admin_ui' gem 'public_ui' end SOURCE GIT PATH GROUP PLATFORMS :source :git :path :group :platforms . source "https://gems.example.com" do gem "some_internal_gem" gem "another_internal_gem" end git "https://github.com/rails/rails.git" do gem "activesupport" gem "actionpack" end platforms :ruby do gem "ruby-debug" gem "sqlite3" end group :development, optional: true do gem "wirble" gem "faker" end :optional --with bundle install . git :ref :branch :tag :submodules git . source Gemfile . Gemfile :source . INSTALL_IF install_if proc lambda . . install_if -> { RUBY_PLATFORM =~ /darwin/ } do gem "pasteboard" end (GEMSPEC) .gemspec https://guides.rubygems.org/specification-reference Rubygems . Gemspec . . Bundler gemspec .gemspec . gemspec (default) . development . (path: '.') . Bundler.setup (require) (load path) . gemspec :path :glob :name :development_group .gemspec (glob) gemspec (: {,*,*/*}.gemspec) .gemspec ( ) . gemspec -- gemspec . (SOURCE PRIORITY) : 1. ( :source :path :git) 2. ( ) git path . ActiveSupport Rails rubygems.org 3. . Bundler 1.13 Bundler . (LOCKFILE) Bundler .lock Gemfile (lockfile) . lockfile : lockfile "/path/to/lockfile.lock" . false : lockfile false . (LOCKFILE PRECEDENCE) : 1. --no-lock bundle install ( lockfile ). 2. --lockfile bundle install. 3. BUNDLE_LOCKFILE. 4. lockfile Gemfile. 5. .lock Gemfile. 2025 GEMFILE(5)