Install & remove
bundle install
Install gems, write Gemfile.lock
bundle add <gem>
Add a gem to the Gemfile and install
bundle add <gem> -v "~> 1.2" -g
development
Add with version and group
bundle add <gem> --skip-install
Edit the Gemfile only
bundle remove <gem>
Remove a gem from the Gemfile
bundle install --jobs <n>
Install in parallel
bundle install --local
Use only gems already on disk
bundle clean
Remove gems the bundle does not use
Update & outdated
bundle update <gem>
Upgrade one gem and what it needs
bundle update --all
Upgrade everything
With the update_requires_all_flag setting on, a bare bundle
update is refused; --all makes the intent explicit.
bundle outdated
List gems with newer versions
bundle update <gem> --conservative
Keep shared dependencies where they are
bundle update --patch
Prefer patch releases only
bundle update --minor
Prefer minor releases at most
bundle update --bundler
Update the locked Bundler version
bundle outdated --only-explicit
Only gems named in the Gemfile
Config & deploy
bundle config
List all settings and where set
bundle config set --local <name> <value>
Set for this project
bundle config set --global <name> <value>
Set for your user
bundle config get <name>
Show one setting
bundle config unset <name>
Remove a setting
bundle config set --local path vendor/bundle
Install gems into the project
bundle config set --local deployment true
Frozen lockfile + vendor/bundle
bundle config set --local frozen true
Fail if the lockfile would change
bundle config set --local without 'development
test'
Skip groups on install
bundle config set --local with <group>
Install an optional group
bundle config set --local jobs <n>
Parallel installs by default
bundle config set --local force_ruby_platform true
Compile native gems from source
bundle cache
Copy gems into vendor/cache
Gemfile syntax
source "https://rubygems.org"
Where gems come from
gem "<name>"
Depend on a gem
gem "<name>", "~> 1.2"
Pessimistic: >= 1.2, < 2.0
gem "<name>", "~> 1.2.3"
Pessimistic: >= 1.2.3, < 1.3
gem "<name>", ">= 1.0", "<
2.0"
Several constraints
gem "<name>", require: false
Install but do not auto-require
gem "<name>", require:
"<path>"
Require path differs from the name
gem "<name>", group: :test
Put one gem in a group
group :development, :test do ... end
Group several gems
ruby "<version>"
Pin the Ruby version
gem "<name>", path:
"<dir>"
Use a local checkout
gem "<name>", git: "<url>",
branch: "<b>"
Use a git repository
gem "<name>", github:
"<user>/<repo>"
GitHub shorthand
gem "<name>", platforms: :windows
Only on given platforms
gem "<name>", source:
"<url>"
Take one gem from another source
source "<url>" do ... end
Gems from a private source
gemspec
Take dependencies from the .gemspec