Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

outdated: option to check only direct/explicit dependencies? #5366

Closed
ivan-kolmychek opened this issue Jan 25, 2017 · 12 comments
Closed

outdated: option to check only direct/explicit dependencies? #5366

ivan-kolmychek opened this issue Jan 25, 2017 · 12 comments

Comments

@ivan-kolmychek
Copy link

ivan-kolmychek commented Jan 25, 2017

We're running bundle outdated automatically against our code base to find and report any outdated dependency, let's say, as a part of the CI build.

To notice that there is a new version that's falling out of our version constraints specified, we also use --no-strict (it's unnecessary right now, ofc, but may be necessary later).

Some pretty useful gems, like pry or even actioncable, are depending on not-the-latest-version of some gems. For instance, at the time of the posting, running bundle outdated with pry 0.10.5 and actioncable 5.0.1 in project produces:

Outdated gems included in the bundle:
  * nio4r (newest 2.0.0, installed 1.2.1)
  * slop (newest 4.4.1, installed 3.6.0)

It would be nice to have a flag (like with --strict/--no-strict) to check only top-level/direct/explicit dependencies. This way the bundle check we use can be set up in two separate checks: 0) for direct dependencies, not strictly and 1) for all dependencies, strictly.

Is there anyone else also interested in this feature?

@ivan-kolmychek
Copy link
Author

ivan-kolmychek commented Jan 26, 2017

I think I should also share the workaround that we use right now, it's based on the fact that bundle outdated accepts the list of gems to check and, in our case, it is called from the shell script.

So, instead of the flag, we can launch first check like this:

cat Gemfile \
  | grep -v '^#' \
  | grep gem \
  | grep -o "[\'\"][a-z0-9_-]*[\'\"]" \
  | grep -o "[a-z0-9_-]*" \
  | xargs bundle outdated

The second check ("for all dependencies strictly") is done via regular bundle outdated --strict ofc.

@LilyReile
Copy link

Seconding this feature request. I always run throughbundle outdated before upgrading rails and it would be nice to have a switch that shows only the actionable items.

@jclif
Copy link

jclif commented Mar 4, 2017

Would definitely love to see this feature as well; we are, similarly, running bundle outdated at the CI level to signal warnings on branches.

@grv87
Copy link

grv87 commented Jun 19, 2017

If you mean, ignore version constraints specified in my Gemfile but still respect constraints specified in gems' metadata, then +1

My current workaround is to manually make temporary clone of repository, remove version constraints from Gemfile. run bundle update and see what is updated.

@ivan-kolmychek
Copy link
Author

ivan-kolmychek commented Jun 21, 2017

@grv87 in a way.

I mean limit the check to only your direct dependencies, completely ignoring their own dependencies.

As an example, if you have a gems A, B and C in your Gemfile, and they depend on some other gems that you haven't specified, like X, Y and Z, with requested flag it would check only A, B and C.

This way you can combine it with already existing flags to customize the checks to suit your particular need.

For example, if you want to NOT ignore the version contstraints specified in Gemfile, you can use the --strict flag, which, according to documentation:

Only list newer versions allowed by your Gemfile requirements.

Also, check out the workaround script I've posted, I think you can customize it for your needs and thus avoid making a copy of repo each time you need that.

@grv87
Copy link

grv87 commented Jun 23, 2017

@ivan-kolmychek, when you say

completely ignoring their own dependencies

what do you mean? Should Bundler still respect their dependencies, just exclude them from output?

Suppose that:

  1. Your Gemfile has
    gem 'A', '~> 1.0'
    gem 'B', '~> 1.0'
    
  2. There is a newer version of gem B 2.0
  3. Gem A 1.0 depends (directly or indirectly) on gem B 1.0

Should Bundler report that gem B is outdated? I believe, no.

Another case is when gem A 1.0 depends on gem C 1.0, and gem B 2.0 depends on C 2.0.

I'm mostly under Windows, so no Shell scripts.

@ivan-kolmychek
Copy link
Author

Should Bundler still respect their dependencies, just exclude them from output?

I think it really depends on your use-case.
We use this "top-level" non-strict outdated check as a way to detect that we have outdated top-level gems, regardless of why exactly are they outdated.

Even if A depends on B 1.0 when there is a newer version, B will not magically become up to date just because of that.

Should Bundler report that gem B is outdated?

Recently we've hit almost exactly the situation you've described - one of the gems we use depended on old version of faraday, but we also use faraday, so "direct update" is not possible.

Which means that we needed to evaluate what our options are (including submitting PR to update the version constraints, forking the gem, replacing faraday with something else in our code, ditching out that dependency if it's not critical, adding faraday to exceptions, etc. etc).

What's the most optimal course of action in similar situation can depend on variety of factors, like what gems are those A and B, how important they are for your project, how wide are they used, etc. etc. So I believe this should be evaluated on case-to-case base, when the situation arises.

But important part is, the notification from check gives you the chance to do that.

I believe, no

If you want it to actually respect dependencies, I think that some kind of an additional flag can also be used, like the --strict or even some new one.

I'm mostly under Windows, so no Shell scripts.

That's actually fine, you can still use shell scripts under the Windows in a variety of ways:

  • first of all, bash is bundled with Git for Windows, so you probably already have it installed on your machine anyway if you're using Git (official download page for Windows uses links to dists from "Git for Windows")
  • and even if you don't use Git for Windows, there are Cygwin, that Ubuntu-on-Windows-10 initiative and Docker for Windows, all of them run bash

(I personally used Cygwin on a few occasions when I was limited to Windows machine by circumstances and it worked pretty well for me.)

Or you can even write the analog in PowerShell and share it here, it's probably not hard.

@grv87
Copy link

grv87 commented Jun 23, 2017

@ivan-kolmychek, ok. So we have two different use cases and require two different solutions.
I won't open new issue for now, until this is resolved.

I know about Git bash and Cygwin and gnuwin32 and so on. Probably I'm lazy enough to go this way for this specific task :) Let's stop this discussion as off-topic.

@Simbul
Copy link

Simbul commented Oct 30, 2017

I also would be interested in this. I'm sure there's a use case somewhere, but I'm struggling to see what's the benefit of bundle outdated returning non-actionable results.

I can see @segiddins marked this as a feature request back in January. Forgive my ignorance, but I couldn't find an answer in the contribution guide: is there a process after that, or is it simply a case of "it's done when it's done"?

@segiddins
Copy link
Member

@Simbul that generally means "seems like a cool idea, we'd be happy to merge a PR adding it"

@peret
Copy link
Contributor

peret commented May 12, 2018

I would also love to see this feature added and took the liberty to prepare a PR!

bundlerbot added a commit that referenced this issue Jun 15, 2018
Add option to filter gem-dependencies from output of 'bundle outdated'

Resolves #5366 by adding a new option '--filter-dependencies' to `bundle outdated`. When present, `outdated` will only check the `gemfile_specs` and skip the `dependency_specs`.
@grzuy
Copy link
Contributor

grzuy commented Aug 17, 2018

For what is worth, as a sort of workaround, I currently use bundle outdated --groups and ignore the gems listed under ==== Without group ====.

colby-swandale pushed a commit that referenced this issue Sep 20, 2018
Add option to filter gem-dependencies from output of 'bundle outdated'

Resolves #5366 by adding a new option '--filter-dependencies' to `bundle outdated`. When present, `outdated` will only check the `gemfile_specs` and skip the `dependency_specs`.

(cherry picked from commit 4eb981a)
colby-swandale pushed a commit that referenced this issue Oct 5, 2018
Add option to filter gem-dependencies from output of 'bundle outdated'

Resolves #5366 by adding a new option '--filter-dependencies' to `bundle outdated`. When present, `outdated` will only check the `gemfile_specs` and skip the `dependency_specs`.

(cherry picked from commit 4eb981a)
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Dec 17, 2018
pkgsr change
* Remove @Prefix@ from ALTERNATIVES file.

## 1.17.2 (2018-12-11)

 - Add compatability for bundler merge with Ruby 2.6

## 1.17.1 (2018-10-25)

 - Convert `Pathname`s to `String`s before sorting them, fixing #6760 and #6758 ([#6761](rubygems/bundler#6761), @alexggordon)

## 1.17.0 (2018-10-25)

No new changes.

## 1.17.0.pre.2 (2018-10-13)

Features:

  - Configure Bundler home, cache, config and plugin directories with `BUNDLE_USER_HOME`, `BUNDLE_USER_CACHE`, `BUNDLE_USER_CONFIG` and `BUNDLE_USER_PLUGIN` env vars ([#4333](rubygems/bundler#4333), @gwerbin)
  - Add `--all` option to `bundle binstubs` that will generate an executable file for all gems with commands in the bundle
  - Add `bundle remove` command to remove gems from the Gemfile via the CLI
  - Improve checking file permissions and asking for `sudo` in Bundler when it doesn't need to
  - Add error message to `bundle add` to check adding duplicate gems to the Gemfile
  - When asking for `sudo`, Bundler will show a list of folders/files that require elevated permissions to write to.

The following new features are available but are not enabled by default. These are intended to be tested by users for the upcoming release of Bundler 2.

  - Improve deprecation warning message for `bundle show` command
  - Improve deprecation warning message for the `--force` option in `bundle install`

## 1.17.0.pre.1 (2018-09-24)

Features:

  - Check folder/file permissions of the Bundle home directory in the `bundle doctor` command ([#5786](rubygems/bundler#5786), @ajwann)
  - Remove compiled gem extensions when running `bundle clean` ([#5596](rubygems/bundler#5596), @akhramov)
  - Add `--paths` option to `bundle list` command ([#6172](rubygems/bundler#6172), @colby-swandale)
  - Add base error class to gems generated from `bundle gem` ([#6260](rubygems/bundler#6260), @christhekeele)
  - Correctly re-install gem extensions with a git source when running `bundle pristine` ([#6294](rubygems/bundler#6294), @wagenet)
  - Add config option to disable platform warnings ([#6124](rubygems/bundler#6124), @agrim123)
  - Add `--skip-install` option to `bundle add` command to add gems to the Gemfile without installation ([#6511](rubygems/bundler#6511), @agrim123)
  - Add `--only-explicit` option to `bundle outdated` to list only outdated gems in the Gemfile ([#5366](rubygems/bundler#5366), @peret)
  - Support adding multiple gems to the Gemfile with `bundle add` ([#6543](rubygems/bundler#6543), @agrim123)
  - Make registered plugin events easier to manage in the Plugin API (@jules2689)
  - Add new gem install hooks to the Plugin API (@jules2689)
  - Add `--optimistic` and `--strict` options to `bundle add` ([#6553](https://github.com/bundler/bundler/issues/6553), @agrim123)
  - Add `--without-group` and `--only-group` options to `bundle list` ([#6564](rubygems/bundler#6564), @agrim123)
  - Add `--gemfile` option to the `bundle exec` command ([#5924](rubygems/bundler#5924), @ankitkataria)

The following new features are available but are not enabled by default. These are intended to be tested by users for the upcoming release of Bundler 2.

  - Make `install --path` relative to the current working directory ([#2048](rubygems/bundler#2048), @igorbozato)
  - Auto-configure job count ([#5808](rubygems/bundler#5808), @segiddins)
  - Use the Gem Version Promoter for major gem updates ([#5993](rubygems/bundler#5993), @segiddins)
  - Add config option to add the Ruby scope to `bundle config path` when configured globally (@segiddins)

## 1.16.6 (2018-10-05)

Changes:

  - Add an error message when adding a gem with `bundle add` that's already in the bundle ([#6341](rubygems/bundler#6341), @agrim123)
  - Add Homepage, Source Code and Chanagelog URI metadata fields to the `bundle gem` gemspec template (@walf443)

Bugfixes:

  - Fix issue where updating a gem resulted in the gem's version being downgraded when `BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS` was set ([#6529](rubygems/bundler#6529), @theflow)
  - Fix some rescue calls that don't specifiy error type (@utilum)
  - Fix an issue when the Lockfile would contain platform-specific gems that it didn't need ([#6491](rubygems/bundler#6491), @segiddins)
  - Improve handlding of adding new gems with only a single group to the Gemfile in `bundle add` (@agrim123)
  - Refactor check for OpenSSL in `bundle env` (@voxik)
  - Remove an unnecessary assignment in Metadata (@voxik)

Documentation:

  - Update docs to reflect revised guidance to check in Gemfile.lock into version control for gems ([#5879](https://github.com/bundler/bundler/issues/5879), @arbonap)
  - Add documentation for the `--all` flag in `bundle update` (@agrim123)
  - Update README to use `bundle add` in usage examples (@hdf1986)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants