Package manager always downgrades specific package for no reason

I recently updated to 1.8.2, but I think this was also happening previously.
I have a package without any dependency forcing it to a lower version, but whenever I run update, the package manager proceeds to downgrade it. I have to proceed to manually update it every time I run a general update, and another round of precompilation follows. Honestly, this exquisitely infuriating. Am I missing something here, and this is happening for some reason I am not aware of?
The package in question here is the MAT.jl package. The Mocking.jl package also seems to be stuck without any restriction, but that’s not main offender here.
I’ll copy a sample of a REPL session where that happens:

(@v1.8) pkg> update
    Updating registry at `~/.julia/registries/General.toml`
   Installed LabelledArrays ──── v1.12.3
   Installed AbstractTrees ───── v0.4.3
   Installed HTTP ────────────── v1.5.1
   Installed VectorizationBase ─ v0.21.54
    Updating `~/.julia/environments/v1.8/Project.toml`
  [cd3eb016] ↑ HTTP v1.5.0 ⇒ v1.5.1
    Updating `~/.julia/environments/v1.8/Manifest.toml`
  [a74b3585] + Blosc v0.7.3
⌅ [f67ccb44] ↓ HDF5 v0.16.12 ⇒ v0.13.6
  [cd3eb016] ↑ HTTP v1.5.0 ⇒ v1.5.1
  [a98d9a8b] ↑ Interpolations v0.13.6 ⇒ v0.14.6
  [2ee39098] ↑ LabelledArrays v1.12.2 ⇒ v1.12.3
⌃ [23992714] ↓ MAT v0.10.3 ⇒ v0.8.1
  [3d5dd08c] ↑ VectorizationBase v0.21.53 ⇒ v0.21.54
  [0b7ba130] + Blosc_jll v1.21.1+0
  [5ced341a] + Lz4_jll v1.9.3+0
        Info Packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`
Precompiling project...
  41 dependencies successfully precompiled in 417 seconds. 367 already precompiled.

(@v1.8) pkg> status --outdated -m
Status `~/.julia/environments/v1.8/Manifest.toml`
⌅ [ab4f0b2a] BFloat16s v0.2.0 (<v0.4.2): CUDA
⌅ [f67ccb44] HDF5 v0.13.6 (<v0.16.12): MAT
⌅ [ef3ab10e] KLU v0.3.0 (<v0.4.0): LinearSolve
⌃ [23992714] MAT v0.8.1 (<v0.10.3)
⌃ [78c3b35d] Mocking v0.7.2 [<v0.7.4], (<v0.7.3)
⌅ [8ea1fca8] TermInterface v0.2.3 (<v0.3.3): Metatheory
⌅ [aabc7e14] MariaDB_Connector_C_jll v3.1.12+0 (<v3.3.2+0): MySQL
⌅ [214eeab7] fzf_jll v0.29.0+0 (<v0.30.0+0): JLFzf

(@v1.8) pkg> update MAT Mocking
    Updating registry at `~/.julia/registries/General.toml`
  No Changes to `~/.julia/environments/v1.8/Project.toml`
    Updating `~/.julia/environments/v1.8/Manifest.toml`
  [a74b3585] - Blosc v0.7.3
  [f67ccb44] ↑ HDF5 v0.13.6 ⇒ v0.16.12
  [23992714] ↑ MAT v0.8.1 ⇒ v0.10.3
  [0b7ba130] - Blosc_jll v1.21.1+0
  [5ced341a] - Lz4_jll v1.9.3+0
Precompiling project...
  3 dependencies successfully precompiled in 10 seconds. 402 already precompiled.

(@v1.8) pkg> status --outdated -m
Status `~/.julia/environments/v1.8/Manifest.toml`
⌅ [ab4f0b2a] BFloat16s v0.2.0 (<v0.4.2): CUDA
⌅ [ef3ab10e] KLU v0.3.0 (<v0.4.0): LinearSolve
⌃ [78c3b35d] Mocking v0.7.2 [<v0.7.4], (<v0.7.3)
⌅ [8ea1fca8] TermInterface v0.2.3 (<v0.3.3): Metatheory
⌅ [aabc7e14] MariaDB_Connector_C_jll v3.1.12+0 (<v3.3.2+0): MySQL
⌅ [214eeab7] fzf_jll v0.29.0+0 (<v0.30.0+0): JLFzf

(@v1.8) pkg> update Mocking
    Updating registry at `~/.julia/registries/General.toml`
  No Changes to `~/.julia/environments/v1.8/Project.toml`
  No Changes to `~/.julia/environments/v1.8/Manifest.toml`

(@v1.8) pkg> update
    Updating registry at `~/.julia/registries/General.toml`
   Installed AbstractAlgebra ─ v0.27.6
  No Changes to `~/.julia/environments/v1.8/Project.toml`
    Updating `~/.julia/environments/v1.8/Manifest.toml`
  [c3fe647b] ↑ AbstractAlgebra v0.27.5 ⇒ v0.27.6
  [a74b3585] + Blosc v0.7.3
⌅ [f67ccb44] ↓ HDF5 v0.16.12 ⇒ v0.13.6
⌃ [23992714] ↓ MAT v0.10.3 ⇒ v0.8.1
  [0b7ba130] + Blosc_jll v1.21.1+0
  [5ced341a] + Lz4_jll v1.9.3+0
        Info Packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`
Precompiling project...
  8 dependencies successfully precompiled in 119 seconds. 400 already precompiled.

You can do e.g.:

pkg> add --preserve=all

which would like to be the default, or at least tried first. There are more options including “tiered Use the tier which will preserve the most version information (this is the default)” which doesn’t seem to be concerned with downgrading vs upgrading…

1 Like

Thanks for the suggestion. Do you have any guess as to what might cause this to happen, even hypothetically?

I think this part “will preserve the most version information”. I would rather want more upgraded, and none downgraded. I’ve seen a case where I didn’t get the latest version could still upgrade to it, so I wouldn’t rule out a bug in the algorithm.

I normally would assume (blindly) that if a package needs to be downgraded for compatibility with a newly installed one, I would accept that and move along, as it would be safer. I am very confused as to why this package would be downgraded without any seeming compatibility restriction. However, I don’t think it’s also safe to avoid automatic downgradings just because, they might be warranted.

a bug in the algorithm

If that’s the case, at least it would be satisfactory if it could be confirmed. I’ll just wait for a few more replies, if possible, before trying to report this in the repo.

I mean it could do better (I confirmed; and you too really seemingly). It’s not a bug in a strict sense, since it DID install what you wanted… and you (the default) just didn’t prevent downgrades. I just wish for a better default, doing better is possible, but would slow the algorithm down.

I don’t think I agree with your interpretation of this not being a bug and slowing down the algorithm.

From my point of view, any package manager should only downgrade a version you already have installed if a newly added package requires an older version for compatibility. In this case, it is downgraded without such a reason. We could assume that a restriction exists and the bug is that it is not displayed in the REPL. If that was the case, then manually updating the downgraded package would be stopped, which doesn’t happen. The other case is that there’s a bug in the that step too, and it fails to detect the restriction at that step and allows the user to update the package.

Also, the microseconds it takes to check version compatibility in toml files vs the time it takes to precompile a bunch of files all over again everytime this bug occurs are such that I think a “heavy but safer” compatibility algorithm is worth it.

But we’re discussing hypothetically, since I myself would like someone else to help us confirm if this is a bug or not.

What’s the content of your Project.toml?

For the main env (where this is also happening, but it happens on all envs):

[deps]
AlphaStableDistributions = "f20549b4-2d50-407f-863c-cdd202ba59a3"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DiffEqFlux = "aae7a2af-3d4f-5e19-a356-7da93b79d9d0"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MySQL = "39abe10b-433b-5dbd-92d4-e302a9df00cd"
Nettle = "49dea1ee-f6fa-5aa6-9a11-8816cee7d4b9"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1"
PkgTemplates = "14b8a8f1-9102-5b29-a752-f990bacb7fe1"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d"
TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
XMLDict = "228000da-037f-5747-90a9-8195ccbf91a5"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[extras]
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"

This indeed seems like a case where the resolver is not giving you the best possible versions.

Doing an add MAT to add the package to the Project seems to work around it:

(downgrade) pkg> add MAT
   Resolving package versions...
    Updating `~/JuliaTests/downgrade/Project.toml`
⌃ [23992714] + MAT v0.8.1
  No Changes to `~/JuliaTests/downgrade/Manifest.toml`

(downgrade) pkg> up
    Updating registry at `~/.julia/registries/General`
    Updating git-repo `https://github.com/JuliaRegistries/General`
    Updating `~/JuliaTests/downgrade/Project.toml`
  [23992714] ↑ MAT v0.8.1 ⇒ v0.10.3
    Updating `~/JuliaTests/downgrade/Manifest.toml`
  [a74b3585] - Blosc v0.7.3
  [f67ccb44] ↑ HDF5 v0.13.6 ⇒ v0.16.12
  [23992714] ↑ MAT v0.8.1 ⇒ v0.10.3
  [0b7ba130] - Blosc_jll v1.21.1+0
  [5ced341a] - Lz4_jll v1.9.3+0

I will open an issue at the Pkg repo about this.

1 Like

Thanks for having a look @kristoffer.carlsson.
I will open an issue myself, no problem.

It seems that

[deps]
AlphaStableDistributions = "f20549b4-2d50-407f-863c-cdd202ba59a3"
DiffEqFlux = "aae7a2af-3d4f-5e19-a356-7da93b79d9d0"

in the project file is enough to recreate this.

At least for AlphaStableDistributions, we just updated the compatibilities yesterday, but not for MAT. But the Project.toml of AlphaStableDistributions allows for compat with MAT 0.10
https://github.com/org-arl/AlphaStableDistributions.jl/blob/master/Project.toml

And DiffEqFlux doesn’t seem to explicitly depend on the package:
https://github.com/SciML/DiffEqFlux.jl/blob/master/Project.toml