mattbrictson / bundle_update_interactive

A stylish interactive mode for Bundler, inspired by `yarn upgrade-interactive`
MIT License
157 stars 5 forks source link

Show gems "held back" by Gemfile pins that can't be updated #37

Closed mattbrictson closed 2 months ago

mattbrictson commented 2 months ago

Problem

Up to this point, update-interactive has only displayed gems that can be updated.

However, there may be gems in a project that are outdated, yet cannot be updated. It is important for a developer to know this. Otherwise they could be dutifully updating their project regularly with update-interactive yet still be out of date.

The typical example is Rails, which is usually declared like this:

gem "rails", "~> 7.0.8"

If the lock file already has Rails 7.0.8.4 installed (i.e. the latest patch in the 7.0 series), then rails can no longer be updated. As a result, rails will not be listed in the gems to update, according to update-interactive.

In this scenario we colloquially say that Rails is being "held back". That is, the ~> version pin the Gemfile is preventing it from being updated to the latest version, which as of this writing is 7.2.0.

Solution

This PR adds the concept of "withheld gems" to update-interactive. We now scan the Gemfile for gems that have version requirements (i.e. "pins") and make an additional call to bundle outdated to see if there are newer versions for these.

If so, an additional section is displayed: "The following gems are being held back and cannot be updated."

This is a new table that shows the requirement (e.g. "~> 7.0.8") in addition to the changelog url, etc. Highlighting based on semver and security vulnerabilities is also performed.

Due to the additional call to bundle outdated, this makes the CLI somewhat slower than it was before this change. (That said, the additional call is made only when necessary. E.g. it is skipped when there are no Gemfile pins.)

In this screenshot, note how sqlite3 is shown as being "held back":

Screenshot 2024-08-13 at 2 34 08 PM

TODO