# Explicit version ranges in compat section in Project.toml?

**URL:** https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147
**Category:** General Usage
**Created:** [October 21, 2019, 8:24pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147 "2019-10-21T20:24:27Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)
#### Post date: [October 21, 2019, 8:24pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/1 "2019-10-21T20:24:28Z")

</div>

Is it possible to specify an explicit version range in the `[compat]` section of a “Project.toml” file? To prevent resolution failure among several packages with inter-dependencies, while also satisfying the new rules for automatic package registration, I need to specify something like

```julia
[compat]
ElasticArrays ">= 0.2, < 2.0"

```

Of course, the above is not legal syntax - but is this possible in some way?

---

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [October 21, 2019, 8:48pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/2 "2019-10-21T20:48:08Z")

</div>

See:

[https://github.com/JuliaLang/Pkg.jl/pull/1410](https://github.com/JuliaLang/Pkg.jl/pull/1410)

---

<div class="post-metadata">

### Author: ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)
#### Post date: [October 21, 2019, 9:03pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/3 "2019-10-21T21:03:18Z")

</div>

Thanks for the link! I so hope that get’s backported to v1.0 - with the current drive to tigher deps bounds, we may end up in dependency version hell without the ability to specify ranges.

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [October 22, 2019, 7:29am UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/4 "2019-10-22T07:29:40Z")

</div>

Can you elaborate? The range syntax is just convenience for things that already work, so not sure why it would be critical or help version resolution.

---

<div class="post-metadata">

### Author: ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)
#### Post date: [October 22, 2019, 7:55am UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/5 "2019-10-22T07:55:49Z")

</div>

> Can you elaborate? The range syntax is just convenience for things that already work

Oh, maybe I got this wrong - is there already a way to specify: “This dependency I need in [v0.2, v2,0)” in a “Project.toml”? That’s basically what I meant with my original question - but I understood @tkf’s reply (thanks!) as “not possible yet”.

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [October 22, 2019, 10:37am UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/6 "2019-10-22T10:37:39Z")

</div>

Yea, you simply list the versions you are compatible, e.g.

```nohighlight
PackageA = "0.2, 0.3, 1, 2"

```

---

<div class="post-metadata">

### Author: ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)
#### Post date: [October 22, 2019, 10:56am UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/7 "2019-10-22T10:56:50Z")

</div>

Argh - it’s right there in the docs, and I didn’t see it _facepalm_. Sorry about the noise!

---

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [October 22, 2019, 4:00pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/8 "2019-10-22T16:00:29Z")

</div>

> [@fredrikekre](#):
>
> The range syntax is just convenience for things that already work

How do you express `PackageA = "0.2 -- 0"`?

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [October 22, 2019, 7:12pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/9 "2019-10-22T19:12:12Z")

</div>

Why do you wanna express that? Then you might as well just leave the bounds empty.

---

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [October 22, 2019, 7:42pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/10 "2019-10-22T19:42:39Z")

</div>

Doesn’t it mean `[0.2, 1)`? [Allow hyphenated ranges in compatability specs by DilumAluthge · Pull Request #1410 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/pull/1410#discussion_r328480875) If not, I’d use `PackageA = "0.2 - 0.9999"`. It certainly is doable with current `[compat]` but I prefer not to repeat so many version numbers.

I guess my question is:

> [@fredrikekre](#):
>
> Yea, you simply list the versions you are compatible, e.g.
> 
> ```julia
> PackageA = "0.2, 0.3, 1, 2"
> 
> ```

Is it compatible with PackageA v0.4 and v0.99?

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [October 22, 2019, 10:00pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/11 "2019-10-22T22:00:56Z")

</div>

My point is that there is a finite set of (breaking) releases that you are compatible with, and you can always list those explicitly.

---

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [October 22, 2019, 10:24pm UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/12 "2019-10-22T22:24:35Z")

</div>

I think one of the common usecases might be for declaring that “this package is loose at compatibility until all the dependencies are stable enough (\>= 1.0)” (\*). This is exactly what `"0.x - 0"` means and it is practically impossible to do with current `[compat]` syntax IIUC.

(\*) Doing this while being compatible with Julia’s version of SemVer is technically possible.

---

<div class="post-metadata">

### Author: ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)
#### Post date: [October 23, 2019, 8:37am UTC](https://discourse.julialang.org/t/explicit-version-ranges-in-compat-section-in-project-toml/30147/13 "2019-10-23T08:37:29Z")

</div>

I agree, I’ve had that use-case. 🙂

Also, sometimes you only need a fairly small subset of features from a package, introduced fairly early on and quite stable afterwards (while other parts of the package are still evolving). So you may actually be compatible with that package at, say [0.2, 2.0). Intervals in Project.toml would be useful here, since otherwise you may end up with “0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 0.11, …, 1.0”.

I think this situation is not uncommon, actually.
