Setting gem versions a Gemfile.

Format

gem GEM_NAME
gem GEM_NAME MIN_OR_COMPAT
gem GEM_NAME, MIN, MAX

Note that double quotes is needed for arguments. Single quotes works but will be replaced by a rufo, the Ruby Formatter.

Unpinned

gem "minima"

Pin

gem "minima", "2.5.1"

Min and max

# Between range. Note upper bounded is needed.
gem "minima", ">= 2.5", "< 3"

Compatible

Using a tilde.

Lock major only.

gem "minima", "~> 2.5"
# Shorthand for >= 2.5, < 3

Lock major and minor.

gem "minima", "~> 2.5.1"
# Shorthand for >= 2.5.1, < 2.6

Lock major but with minimum version.

gem "minima", "~> 2.5", ">= 2.5.1"