How to find out what packages are preventing another from being upgraded?

A common scenario is that in your current opam state, you have package X which could be upgraded, but package Y is also installed and has an upper-bound preventing X from being upgraded. In the past, my recollection is that opam would provide some very helpful output upon running opam upgrade X that would at least tell me that package Y is the problem that needs to be dealt with.

That is why I was surprised to see the following output when I ran opam upgrade cohttp on opam 2.2.1 this morning:

Everything as up-to-date as possible (run with --verbose to show unavailable
upgrades).

The following packages are not being upgraded because the new versions conflict
with other installed packages:
  - cohttp.6.0.0~beta2
However, you may "opam upgrade" these packages explicitly, which will ask
permission to downgrade or uninstall the conflicting packages.
Nothing to do.

(The same happens with --verbose.) It’s unclear what I am supposed to do — the tool seems to be inviting me to run opam upgrade cohttp, but this is what I just did.

I am starting to think that I am misinterpreting the message :wink: After re-reading, it is looking like cohttp is conflicting with itself somehow, which I don’t quite understand but sounds like progress.

if you do opam upgrade cohttp or opam install cohttp.6.0.0~beta2 you will get more details on what are the conflicts which must be resolved to allow installing this version.

1 Like

No, as I stated in my post, this was already the output of running “opam upgrade cohttp”!

That looks really odd. Do you have cohttp pinned?

1 Like

I don’t think so, but I will double check when I get home… Let me know if there are any other diagnostic commands I can run that would help :slight_smile:

opam install cohttp.6.0.0~beta2 as highlighted by @Khady definitely works.
For example in my case i get:

$ opam upgrade cohttp
Everything as up-to-date as possible (run with --verbose to show unavailable upgrades).

The following packages are not being upgraded because the new versions conflict with other installed packages:
  - cohttp.6.0.0~beta2
However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages.
Nothing to do.
$ opam install cohttp.6.0.0~beta2
The following actions will be performed:
=== downgrade 3 packages
  ↘ conduit          7.1.0 to 6.2.3       [required by conduit-lwt]
  ↘ conduit-lwt      7.1.0 to 6.2.3       [required by cohttp-lwt-unix]
  ↘ conduit-lwt-unix 7.1.0 to 6.2.3       [required by cohttp-lwt-unix]
=== recompile 3 packages
  ↻ github           4.4.1                [uses cohttp]
  ↻ github-unix      4.4.1                [uses cohttp]
  ↻ opam-publish     2.4.0 (pinned)       [uses github]
=== upgrade 3 packages
  ↗ cohttp           5.3.1 to 6.0.0~beta2
  ↗ cohttp-lwt       5.3.0 to 6.0.0~beta2 [uses cohttp]
  ↗ cohttp-lwt-unix  5.3.0 to 6.0.0~beta2 [uses cohttp]
=== install 1 package
  ∗ http             6.0.0~beta2          [required by cohttp]

Proceed with ↘ 3 downgrades, ↻ 3 recompilations, ↗ 3 upgrades and ∗ 1 installation? [y/n] n

The reason is that by default opam upgrade tries to make sure that no other installed packages are going to be downgraded by trying to upgrade that one package further. The UI for this could be improved by trying to give some sort of succint reason for it but that seems complicated. However the main problem here is that this version of cohttp is purposefully hidden (using the avoid-version flag) as it is a pre-release, opam shouldn’t show this message with this version of cohttp in the first place. I’ve opened a ticket and will try to fix it: avoid-version packages should be ignored when opam upgrade refuses to upgrade · Issue #6271 · ocaml/opam · GitHub

This is an issue with the message. What it meant is that it’s inviting you to do opam upgrade cohttp.6.0.0~beta2. I’ll also try to look for a good way to rewrite this sentence: opam upgrade pkg refuses to upgrade · Issue #6270 · ocaml/opam · GitHub

3 Likes