Gemfile DSL Reference
A comprehensive guide to the Gemfile Domain Specific Language (DSL) supported by Rad.
Introduction
Rad uses the same Gemfile format as Bundler, ensuring compatibility with existing Ruby projects. The Gemfile is a Ruby file that defines the gems your application depends on and optionally where they should be sourced from.
Basic Structure
A basic Gemfile starts with a source definition and lists the required gems:
Source Declaration
The source declaration specifies where to fetch gems from:
Gem Declarations
Basic Gem Declaration
Version Requirements
Rad supports all standard version requirement formats with an advanced dependency resolver that makes Bundler look like it's using an abacus:
Format | Description | Example |
---|---|---|
"= 1.0" | Exactly version 1.0 | gem "rails", "= 7.1.0" |
"!= 1.0" | Any version except 1.0 | gem "rails", "!= 7.0.0" |
> 1.0 | Any version greater than 1.0 | gem "rails", > 7.0.0 |
< 2.0 | Any version less than 2.0 | gem "rails", < 8.0.0 |
>= 1.0 | Version 1.0 or greater | gem "rails", >= 7.0.0 |
<= 2.0 | Version 2.0 or less | gem "rails", <= 7.1.0 |
~> 1.0 | Pessimistic version constraint (>= 1.0, < 2.0) | gem "rails", ~> 7.0 |
~> 1.0.1 | Pessimistic version constraint (>= 1.0.1, < 1.1.0) | gem "rails", ~> 7.0.6 |
>= 1.0, < 2.0 | Multiple requirements (ranges) | gem "rails", >= 7.0.0, < 8.0.0 |
~>
) is especially useful for ensuring compatible updates while avoiding potentially breaking changes in major version updates.Gem Options
Gems can have additional options that specify how they should be handled:
Alternate Sources
Gems can be loaded from different sources, including Git repositories and local paths:
Groups
Gems can be organized into groups, which can be selectively installed:
You can install gems without certain groups:
Platform-specific Gems
Gems can be specified for particular platforms with Rad's platform detection that's so accurate it's almost creepy:
Gemfile.rad
Rad is fully compatible with existing Gemfiles and automatically generates a Gemfile.rad
file when resolving dependencies. This file is used to store Rad-specific metadata and optimizations.
The Gemfile.rad
file should be committed to version control along with your Gemfile
and Gemfile.lock
.