# Specify version range with specific versions in \[compat\] on 0.7/1.0?

**URL:** https://discourse.julialang.org/t/specify-version-range-with-specific-versions-in-compat-on-0-7-1-0/15018
**Category:** General Usage
**Created:** [September 16, 2018, 2:57pm UTC](https://discourse.julialang.org/t/specify-version-range-with-specific-versions-in-compat-on-0-7-1-0/15018 "2018-09-16T14:57:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [September 16, 2018, 2:57pm UTC](https://discourse.julialang.org/t/specify-version-range-with-specific-versions-in-compat-on-0-7-1-0/15018/1 "2018-09-16T14:57:24Z")

</div>

Is it possible to specify a version range in the `[compat]` section in Project.toml?

In particular, I’d like to specify a range including both 0.7 and 1.0, indicating that the package works for all versions from 0.7 to 1, including both, but not any version with e.g. 2.x, as a safety measure for when that version will be released.

I’ve tried writing

```julia
[compat]
julia = ">=0.7, <2"

```

according to [the docs](https://docs.julialang.org/en/v1/stdlib/Pkg/#Version-specifier-format-1)

> The intersection of multiple version specifiers can be formed by comma separating indiviual version specifiers.

and that seemed to work fine, but when trying it out by changing the upper bound to `1.0`, it added without error on 1.0, even though it should only be possible to add that package to 0.7, if I understand correctly.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [September 16, 2018, 3:15pm UTC](https://discourse.julialang.org/t/specify-version-range-with-specific-versions-in-compat-on-0-7-1-0/15018/2 "2018-09-16T15:15:21Z")

</div>

As documented in those docs, note that you can use the care notation for exactly this purpose, ie

```nohighlight
^1 = [1.0.0, 2.0.0)

```

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [September 16, 2018, 3:18pm UTC](https://discourse.julialang.org/t/specify-version-range-with-specific-versions-in-compat-on-0-7-1-0/15018/3 "2018-09-16T15:18:29Z")

</div>

Yes, that works for `[1.0, 2.0)` - but what about `[0.7, 2.0)`? Or any version jump greater than one major version? Using just `^1` gives a warning on 0.7, even though it’s very reasonable that code written for 1.0 also works on 0.7.

EDIT: ah, did you mean `julia = ">= 0.7, ^1"`? That indeed seems to work, although cumbersome when it’s possible to support multiple major version jumps, e.g. `">=0.7, ^1, ^2, ^3, ..."`… Is there a better way?

Adding on to this, the docs talk about the “intersection” of version ranges, but specifying `julia = ">= 0.7, ^0"` does not prevent a package from being `add`ed on 1.0 - in fact, it works without any warning at all. Is there some undocumented precedence? Or is this just an unlikely (hopefully never again relevant) edge case with the major version jump `0 -> 1`?

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [September 16, 2018, 7:55pm UTC](https://discourse.julialang.org/t/specify-version-range-with-specific-versions-in-compat-on-0-7-1-0/15018/4 "2018-09-16T19:55:09Z")

</div>

> [@Sukera](#):
>
> Adding on to this, the docs talk about the “intersection” of version ranges, but specifying `julia = ">= 0.7, ^0"` does not prevent a package from being `add` ed on 1.0 - in fact, it works without any warning at all.

The reason I’m asking about this is because this is leading me to believe that the intersection does in fact not work as described in the documentation, as both those conditions together should prevent the package from being installed on 1.x, as I understand it. Those conditions should be equal to a version range of `[0.7, 1.0)` - note the jump in major version, which I don’t think can be expressed otherwise. Since that example didn’t work for me, I think it also won’t work for `[0.7, 2.0)` - no way for me to test that at the moment though 😕

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [September 17, 2018, 7:42am UTC](https://discourse.julialang.org/t/specify-version-range-with-specific-versions-in-compat-on-0-7-1-0/15018/5 "2018-09-17T07:42:27Z")

</div>

I think that `julia = ">= 0.7, ^1"` should solve your original problem (not allowing a new major version until it is tested), and supporting a large number of major (= breaking API changes) versions of some dependency (or the major language) is not a typical use case, as it would involve a lot of conditional boilerplate code. In the unlikely case this happens, adding an extra `^n` is not a major burden.

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [September 17, 2018, 8:02am UTC](https://discourse.julialang.org/t/specify-version-range-with-specific-versions-in-compat-on-0-7-1-0/15018/6 "2018-09-17T08:02:36Z")

</div>

> [@Tamas\_Papp](#):
>
> I think that `julia = ">= 0.7, ^1"` should solve your original problem (not allowing a new major version until it is tested)

That it should, so I’ll mark your answer as the solution - however, it’s still not clear if that bound actually works as intended, since `julia = ">=0.7, ^0"` still is possible to be added to 1.0…
