ruby / ruby/rubygems

Feature: Ignore exact versions during `bundle outdated` with a new flag `--ignore-exact`

Open
#9,539 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bundler
Dominant language
Ruby
Stars
4k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
81

Description

TL;DR It would be great if bundle outdated has an --ignore exact flag to skip over gems with a = in their version. I would also like to take a stab at implementing this if you agree it is a useful addition to the outdated subcommand.

Describe the problem as clearly as you can

We regularly update all our outdated gems using bundle outdated --only-explicit. However, each project normally has a couple of gems that are defined like so e.g.:

gem 'faraday', '= 2.7.12' # NOTE: Salesforce gem has a transitive dependency on this. Cannot upgrade until restforce gem is updated.

This gem, as an example, cannot be updated because of an outdated shared dependency. There are many other reasons why we would want to explicitly lock a gem at a specific version.

I would like to run bundle outdated --only-explicit --ignore-exact and have it filter out outdated gems that have an exact version in our gemfile.

By doing so, we can integrate bundle outdated into our pipelines and ensure we are always up to date. Right now, it would exit with a status of 1 with these gems specified.

Before
root@bbf593aba375:/# bundle outdated --only-explicit
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...

Gem                   Current  Latest  Requested  Groups
google-ads-googleads  35.2.0   40.1.0  = 35.2.0   default
pagy                  9.4.0    43.5.3  ~> 9.4.0   default
pipedrive-connect     2.0.1    2.1.2   = 2.0.1    default
view_component        4.9.0    4.10.0  ~> 4.9.0   default

root@bbf593aba375:/# echo $?
1
After
root@bbf593aba375:/# bundle outdated --only-explicit --ignore-exact
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...

Gem                   Current  Latest  Requested  Groups
pagy                  9.4.0    43.5.3  ~> 9.4.0   default
view_component        4.9.0    4.10.0  ~> 4.9.0   default

root@bbf593aba375:/# echo $?
1

and assuming we resolve the two outdated gems:

root@bbf593aba375:/# bundle outdated --only-explicit --ignore-exact
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...

Bundle up to date!

root@bbf593aba375:/# echo $?
0
More on behaviour of flag

Developers normally specify an exact version in one of two ways:

  • "1.2.3"
  • "= 1.2.3"

The version pin without the equals is normally added when copying and pasting, and it's ambiguous as to whether or not the intention is truly to use that exact version. However, when prepending with =, the developer is signalling that they do indeed wish to use that exact version, and not anything else.

Therefore, making the --ignore-exact flag only ignore gems explicitly marked with = could be considered safe behaviour for this flag.

Did you try upgrading rubygems & bundler?

I've checked, and bundler 4.0.11, the latest as of creating this issue, does not have this feature.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the bundle outdated entry point and its existing --only-explicit option. Trace how requested versions are classified, distinguishing explicit = pins from other constraints, and verify the command's displayed results and exit status against the before-and-after examples. Done means --ignore-exact omits only gems explicitly marked with =.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.