Skip to content

Extend cabal outdated to multi-package #8283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
andreasabel opened this issue Jul 12, 2022 · 10 comments · May be fixed by #10878
Open

Extend cabal outdated to multi-package #8283

andreasabel opened this issue Jul 12, 2022 · 10 comments · May be fixed by #10878
Assignees

Comments

@andreasabel
Copy link
Member

E.g. in the root of this repo:

cabal[master]$ cabal outdated
Error: cabal: No cabal file found.
Please create a package description file <pkgname>.cabal

It would be helpful if cabal outdated could also deal with a cabal.project file (instead of .cabal files only), similar to cabal build etc. It could list the outdated dependencies for all packages mentioned in cabal.project (grouped per package).

@erikd
Copy link
Member

erikd commented Oct 17, 2023

From HEAD of the cabal repo I get:

cabal run -- cabal outdated
Error: [Cabal-7654]
No cabal file found.
Please create a package description file <pkgname>.cabal

so this is definitely not working now.

@erikd erikd self-assigned this Oct 17, 2023
@andreabedini
Copy link
Collaborator

Copying here some comments from @hvr:

Here's some ideas for how to improve cabal outdated with the nix-local-build UI in mind:

cabal outdated should support target-selectors like new-build et al:

cabal outdated all would then iterate over all local packages configured in cabal.project and check all components for over-constricted bounds.

And it also makes sense to limit outdated to some components, i.e. if only care about a few components (and e.g. not the testsuite): cabal outdated lib:foo exe:doo would only check the two named components in whichever local package they're located.

Conversely, we have special names to e.g. refer to all testsuites in the target-selector; so you could also say cabal outdated tests to iterate over all test-suite components in your cabal.project.

cabal outdated already supports cabal.project.freeze; however, it would be convenient to have a variant which consults the last computed install-plan (and possibly compute one if it's needs (re)computation); IOW, a variant that combines cabal new-freeze with cabal outdated --new-freeze-file but without generating/overwriting an existing cabal.project.freeze file.

@erikd
Copy link
Member

erikd commented Oct 17, 2023

cabal outdated all would then iterate over all local packages configured in cabal.project

Isn't this functionality already available somewhere else for all of the new commands to use?

@andreabedini
Copy link
Collaborator

If you just want all the local packages you can take inspiration from here

freezeAction flags@NixStyleFlags{..} extraArgs globalFlags = do
unless (null extraArgs) $
die' verbosity $
"'freeze' doesn't take any extra arguments: "
++ unwords extraArgs
ProjectBaseContext
{ distDirLayout
, cabalDirLayout
, projectConfig
, localPackages
, buildSettings
} <-
establishProjectBaseContext verbosity cliConfig OtherCommand

If you want to accept a target like Herbert is saying you need to do something like this
https://github.com/haskell/cabal/blob/master/cabal-install/src/Distribution/Client/CmdListBin.hs#L100C3-L100C26

Note that Distribution.Client.CmdOutdated is an odd-ball. It follows the naming of v2 commands (Cmd*) and it uses ProjectFlags but it looks like it follows the pattern of v1 commands after that.

mpickering added a commit that referenced this issue Mar 27, 2025
This commit updates the outdated command to the new v2 architecture:

- Transform the old `outdated` command into a new v2-style command `v2-outdated`
- Support three modes of operation:
  - Check for outdated dependencies in v1-style freeze file
  - Check for outdated dependencies in project context (cabal.project & cabal.project.freeze)
  - Check for outdated dependencies in local packages

Since the `cabal outdated` command now supports the v2-architecture, you
can request to run the `v2-outdated` command on any target.

I also introduced the `resolveTargetsFromLocalPackages` which resolves
which local packages targets refer to without having to run the solver.
This will be useful for `cabal check` as well.

A change in behaviour from before is that the package description is
flattened, so all bounds will be warned about rather than those in
conditional branches being ignored.

Fixes #8283
mpickering added a commit that referenced this issue Mar 27, 2025
This commit updates the outdated command to the new v2 architecture:

- Transform the old `outdated` command into a new v2-style command `v2-outdated`
- Support three modes of operation:
  - Check for outdated dependencies in v1-style freeze file
  - Check for outdated dependencies in project context (cabal.project & cabal.project.freeze)
  - Check for outdated dependencies in local packages

Since the `cabal outdated` command now supports the v2-architecture, you
can request to run the `v2-outdated` command on any target.

I also introduced the `resolveTargetsFromLocalPackages` which resolves
which local packages targets refer to without having to run the solver.
This will be useful for `cabal check` as well.

A change in behaviour from before is that the package description is
flattened, so all bounds will be warned about rather than those in
conditional branches being ignored.

Fixes #8283
@mpickering
Copy link
Collaborator

I have implemented v2-outdated on this branch - https://github.com/haskell/cabal/tree/wip/v2-outdated

If anyone wishes to try it out that would be good. I will tidy up the tests tomorrow.

# cabal outdated all
Configuration is affected by the following files:
- cabal.project
Outdated dependencies:
template-haskell >=2.3.0 && <2.3.1 (latest: 2.4.0.0, package-a-0.1.0.0:lib:package-a)
template-haskell >=2.3 && <2.4 (latest: 2.4.0.0, package-a-0.1.0.0:lib:package-a)
base >=3.0 && <3.5 (latest: 4.0.0.0, package-b-0.1.0.0:lib:package-b)

This also fixes a bug where dependencies in conditional branches were not taken into account.

It didn't seem worth it to to keep the old v1-outdated codepath.

@ulysses4ever
Copy link
Collaborator

It didn't seem worth it to keep the old v1-outdated codepath.

I agree with this in principle, but I'd like to point out that last time a move like that prompted a somewhat intense debate: #9107

@andreasabel
Copy link
Member Author

Is v1-outdated doing something not covered by v2-outdated?

@mpickering
Copy link
Collaborator

v2-outdated does everything that v1-outdated did.

  1. Checks bounds in a v1-freeze-file
  2. Checks bounds which come from the project context (cabal.project.freeze, cabal.project, command line etc)
  3. Check bounds in local packages

It could also be extended to check bounds for non-local packages, but this seemed like overkill.

Where is it different.

  1. Works exactly the same
  2. Checks the bounds for the project context, not just a cabal.project.freeze file. Which seems like more correct behaviour to me since a cabal.project.freeze file is no different from a cabal.project file. You might specify your freeze constraints in
  3. Uses the project selector to work out which bounds to check and doesn't ignore bounds in flag sections.

If you could try out the patch it would be greatly appreciated @andreasabel. Perhaps I could also quickly add support for build-tool-depends as well if you could guide this collaboration.

@andreasabel
Copy link
Member Author

If you could try out the patch it would be greatly appreciated @andreasabel.

I am happy to try if you put up a (draft) PR.

mpickering added a commit that referenced this issue Mar 28, 2025
This commit updates the outdated command to the new v2 architecture:

- Transform the old `outdated` command into a new v2-style command `v2-outdated`
- Support three modes of operation:
  - Check for outdated dependencies in v1-style freeze file
  - Check for outdated dependencies in project context (cabal.project & cabal.project.freeze)
  - Check for outdated dependencies in local packages

Since the `cabal outdated` command now supports the v2-architecture, you
can request to run the `v2-outdated` command on any target.

I also introduced the `resolveTargetsFromLocalPackages` which resolves
which local packages targets refer to without having to run the solver.
This will be useful for `cabal check` as well.

A change in behaviour from before is that the package description is
flattened, so all bounds will be warned about rather than those in
conditional branches being ignored.

Fixes #8283
@mpickering mpickering linked a pull request Mar 28, 2025 that will close this issue
8 tasks
@mpickering
Copy link
Collaborator

Thanks @andreasabel, see #10878

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants