Upper bound for minor version of a dependency

Is there a way of setting an upper bound for the minor version of a dependency in the [compat] section of Project.toml?

I want to set the compatible versions of a dependency to the range [1, 1.5] or [1, 1.6). This is because that dependency has actually broken things on a minor version update, from 1.5.9 to 1.6.0, so I want to declare that my package X depends on package Y but up to 1.5.9 at most.

I have tried to set it as X = "1, 1.5" and X = "1, <1.6", but Julia is choosing to install 1.6.0. I have also tried X = "<1.6", which actually works; but that seems to not follow the guidelines of the General registry, because I get:

The following guidelines were not met:

The following dependencies do not have a [compat] entry that is upper-bounded and only includes a finite number of breaking releases: X

I’m using Julia 1.8.5 / 1.9.

I think you want a tilde:

[compat]
PkgA = "~1.2.3" # [1.2.3, 1.3.0)
PkgB = "~1.2"   # [1.2.0, 1.3.0)
PkgC = "~1"     # [1.0.0, 2.0.0)
PkgD = "~0.2.3" # [0.2.3, 0.3.0)
PkgE = "~0.0.3" # [0.0.3, 0.0.4)
PkgF = "~0.0"   # [0.0.0, 0.1.0)
PkgG = "~0"     # [0.0.0, 1.0.0)

https://pkgdocs.julialang.org/v1/compatibility/#Tilde-specifiers

1 Like

Thank you for your prompt reply!

If I use the tilde, as in X = "~1.5", then it will constrain it to versions [1.5.0, 1.6.0). But that seems a bit too constrained compared to the [1.0.0, 1.6.0) which is what I’d like to specify.

The tilde might solve the issue with the auto merge to the General registry, though. I’ll try it out.

You can use hyphens for an explicit range.

[compat]
PkgA = "1.2.3 - 4.5"   # 1.2.3 - 4.5.* = [1.2.3, 4.6.0)
PkgA = "1.2.3 - 4"     # 1.2.3 - 4.*.* = [1.2.3, 5.0.0)
PkgA = "1.2 - 4.5"     # 1.2.0 - 4.5.* = [1.2.0, 4.6.0)
PkgA = "1.2 - 4"       # 1.2.0 - 4.*.* = [1.2.0, 5.0.0)
PkgA = "1 - 4.5"       # 1.0.0 - 4.5.* = [1.0.0, 4.6.0)
PkgA = "1 - 4"         # 1.0.0 - 4.*.* = [1.0.0, 5.0.0)
PkgA = "0.2.3 - 4.5"   # 0.2.3 - 4.5.* = [0.2.3, 4.6.0)
PkgA = "0.2.3 - 4"     # 0.2.3 - 4.*.* = [0.2.3, 5.0.0)
PkgA = "0.2 - 4.5"     # 0.2.0 - 4.5.* = [0.2.0, 4.6.0)
PkgA = "0.2 - 4"       # 0.2.0 - 4.*.* = [0.2.0, 5.0.0)
PkgA = "0.2 - 0.5"     # 0.2.0 - 0.5.* = [0.2.0, 0.6.0)
PkgA = "0.2 - 0"       # 0.2.0 - 0.*.* = [0.2.0, 1.0.0)

https://pkgdocs.julialang.org/v1/compatibility/#Hyphen-specifiers

2 Likes

Ah yes, I think X = "1 - 1.5" works! Thank you! :smiley:

You don’t need it now that you have solved it but a convenient way to get working compat is to use GitHub - GunnarFarneback/PackageCompatUI.jl: Terminal UI for [compat] section of Julia Project.toml files.

1 Like

Interesting. Thanks for sharing!